Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoExecutionException


        {
            if (throwable instanceof MojoExecutionException)
            {
                throw (MojoExecutionException)throwable;
            }
            throw new MojoExecutionException("An error occured creating profile site document '" +
                this.project.getArtifactId() + "'",
                ExceptionUtils.getRootCause(throwable));
        }
    }
View Full Code Here


                        destFile);
            }
        }
        catch (Exception e)
        {
            throw new MojoExecutionException("Error copying file from " + sourceFile + " to " + destFile, e);
        }
    }
View Full Code Here

            unArchiver.setDestDirectory(location);
            unArchiver.extract();
        }
        catch (NoSuchArchiverException e)
        {
            throw new MojoExecutionException("Unknown archiver type", e);
        }
        catch (IOException e)
        {
            e.printStackTrace();
            throw new MojoExecutionException("Error unpacking file: " +
                    file.getAbsolutePath() + " to: " + location + "\r\n" + e.toString(), e);
        }
        catch (ArchiverException e)
        {
            e.printStackTrace();
            throw new MojoExecutionException("Error unpacking file: " +
                    file + " to: " + location + "\r\n" + e.toString(), e);
        }
    }
View Full Code Here

                        throw e;
                    }
                }
            } catch (Throwable e) {
                e.printStackTrace();
                throw new MojoExecutionException(e.getMessage(), e);
            }
        }
    }
View Full Code Here

        // Create directory if not existing
        this.outputFile.getParentFile().mkdirs();

        // Build artifacts from modules
        if (this.modules == null) {
            throw new MojoExecutionException("No modules element has been set");
        }

        // Create list
        List<Artifact> artifacts = new ArrayList<Artifact>();

        // for each module, build artifact.
        for (Module module : this.modules) {
            String groupId = module.getGroupId();
            String artifactId = module.getArtifactId();
            String type = module.getType();
            String version = module.getVersion();
            String classifier = module.getClassifier();

            if (groupId == null) {
                throw new MojoExecutionException("No groupdId set for module '" + module + "'");
            }
            if (artifactId == null) {
                throw new MojoExecutionException("No artifactId set for module '" + module + "'");
            }

            if (type == null) {
                getLog().debug("No type set for module '" + module + "', assume it is jar type");
                type = "jar";
                module.setType(type);
            }

            if (version == null) {
                // try to find version with dependency management
                DependencyManagement dependencyManagement = this.project.getDependencyManagement();

                if (dependencyManagement != null) {
                    // try to find a version for this component
                    List<Dependency> dependencies = dependencyManagement.getDependencies();
                    if (dependencies != null) {
                        for (Dependency dependency : dependencies) {
                            getLog().debug("Dependency = " + dependency);
                            if (groupId.equals(dependency.getGroupId()) && artifactId.equals(dependency.getArtifactId())
                                    && type.equals(dependency.getType())) {
                                getLog().debug("Using version of dependency management" + dependency.getVersion());
                                version = dependency.getVersion();
                                break;
                            }
                        }
                    }
                }
                if (version == null) {
                    throw new MojoExecutionException("No version set for module '" + module + "'");
                }
            }
            Artifact artifact = null;
            if (classifier != null) {
                artifact = this.artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
            } else {
                artifact = this.artifactFactory.createBuildArtifact(groupId, artifactId, version, type);
            }
            getLog().debug("Built Artifact = " + artifact);

            // now resolve this artifact
            try {
                this.artifactResolver.resolve(artifact, this.repositories, this.localRepository);
            } catch (ArtifactResolutionException e) {
                throw new MojoExecutionException("Cannot resolve artifact '" + artifactId + "'.", e);
            } catch (ArtifactNotFoundException e) {
                throw new MojoExecutionException("Artifact '" + artifactId + "' not found.", e);
            }

            // Add artifact
            artifacts.add(artifact);

        }

        FileWriter fileWriter = null;
        try {
            // Create file writer
            try {
                fileWriter = new FileWriter(this.outputFile);
            } catch (IOException e) {
                throw new MojoExecutionException("Cannot create a file on '" + this.outputFile + "'", e);
            }

            // Write the name of the files
            for (Artifact artifact : artifacts) {
                try {
                    getLog().debug("Writing " + artifact.getFile().getName());
                    fileWriter.write(artifact.getFile().getName());
                    fileWriter.write("\n");
                } catch (IOException e) {
                    throw new MojoExecutionException("Cannot write the line for Artifact '" + artifact + "' in the file '"
                            + this.outputFile + "'", e);
                }
            }
        } finally {
            // close file writer
View Full Code Here

                                                       throws MojoExecutionException {

        if (configXmlFile != null && !configXmlFile.equals("")) {
            File file = new File(configXmlFile);
            if (!file.exists() || !file.isFile()) {
                throw new MojoExecutionException("EasyBeans can not be started. "
                          + "Your EasyBeans configuration file is not found at [" + file.getAbsolutePath() + "].");
            }
        }

        EasyBeansPluginServer server = new EasyBeansPluginServer(configXmlFile, partialConfigXmlFiles);
        IPersistenceListener persistenceListener = null;
        PersistenceManager manager = PersistenceManager.getInstance();
       
        if (supportAllPersistenceManager) {
            manager.loadAllDependencies(resolver);
        } else {
            persistenceListener = manager.getPersistenceListener(resolver);
        }

        server.start(persistenceListener);

        if (!server.isStarted()) {
            throw new MojoExecutionException("EasyBeans can not be started. "
                      + "Maybe another instance of server is launched.");
        }

        return server;
    }
View Full Code Here

        RemoteEasyBeansPluginServer server = null;
        try {
            server = new RemoteEasyBeansPluginServer(hostname, stopPort);
        } catch (IOException ex) {
            throw new MojoExecutionException("No EasyBeans server found at \"" + hostname + ":" + stopPort + "\"");
        }
        return server;
    }
View Full Code Here

      ArrayList<String> includes = new ArrayList<String>();
      includes.add("**/*");
      projectHelper.addResource(project, resourceDir, includes, Collections.EMPTY_LIST);
    } catch (IOException e) {
      getLog().error("Could not create directory " + resourceDir, e);
      throw new MojoExecutionException("Could not created directory " + resourceDir);
    }
  }
View Full Code Here

      }
      getLog().info("Writing modules script " + profile.getAbsolutePath());
      FileUtils.fileWrite(profile.getAbsolutePath(), sb.toString());
    } catch (IOException e) {
      getLog().error("Failed to write modules script", e);
      throw new MojoExecutionException("Failed to write modules script");
    }
  }
View Full Code Here

        }
        log.info("Creating directory " + dojoDirectory.getAbsolutePath());
        FileUtils.mkdir(dojoDirectory.getAbsolutePath());
      } catch (IOException e) {
        log.error("Failed to install dojo build environment", e);
        throw new MojoExecutionException("Failed to install dojo build environment");
      }
      unpackArchive(dojoArtifact.getFile(), dojoDirectory);
    }
    cleanPrevious();
  }
View Full Code Here

TOP

Related Classes of org.apache.maven.plugin.MojoExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.