List of usage examples for org.apache.maven.plugin MojoExecutionException MojoExecutionException
public MojoExecutionException(String message, Throwable cause)
MojoExecutionException
exception wrapping an underlying Throwable
and providing a message
. From source file:cn.wanghaomiao.maven.plugin.seimi.SeimiMojo.java
License:Apache License
/** * Executes the WarMojo on the current project. * * @throws MojoExecutionException if an error occurred while building the webapp * @throws MojoFailureException if an error. *//*from ww w. j a va2 s . co m*/ public void execute() throws MojoExecutionException, MojoFailureException { File warFile = getTargetWarFile(); try { performPackaging(warFile); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e); } catch (ManifestException e) { throw new MojoExecutionException("Error assembling WAR", e); } catch (IOException e) { throw new MojoExecutionException("Error assembling WAR", e); } catch (ArchiverException e) { throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e); } }
From source file:cn.wanghaomiao.maven.plugin.seimi.util.ClassesPackager.java
License:Apache License
/** * Package the classes/*from www .ja va 2 s .c om*/ * * @param classesDirectory the classes directory * @param targetFile the target file * @param jarArchiver the jar archiver to use * @param session the current session * @param project the related project * @param archiveConfiguration the archive configuration to use * @throws MojoExecutionException if an error occurred while creating the archive */ public void packageClasses(File classesDirectory, File targetFile, JarArchiver jarArchiver, MavenSession session, MavenProject project, MavenArchiveConfiguration archiveConfiguration) throws MojoExecutionException { try { final MavenArchiver archiver = new MavenArchiver(); archiver.setArchiver(jarArchiver); archiver.setOutputFile(targetFile); archiver.getArchiver().addDirectory(classesDirectory); archiver.createArchive(session, project, archiveConfiguration); } catch (ArchiverException e) { throw new MojoExecutionException("Could not create classes archive", e); } catch (ManifestException e) { throw new MojoExecutionException("Could not create classes archive", e); } catch (IOException e) { throw new MojoExecutionException("Could not create classes archive", e); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Could not create classes archive", e); } }
From source file:cn.wanghaomiao.maven.plugin.seimi.WarManifestMojo.java
License:Apache License
/** * Executes this mojo on the current project. * * @throws MojoExecutionException if an error occurred while building the webapp */// ww w .ja v a 2s. c o m public void execute() throws MojoExecutionException { File manifestDir = new File(getWarSourceDirectory(), "META-INF"); if (!manifestDir.exists()) { manifestDir.mkdirs(); } File manifestFile = new File(manifestDir, "MANIFEST.MF"); MavenArchiver ma = new MavenArchiver(); ma.setArchiver(warArchiver); ma.setOutputFile(manifestFile); PrintWriter printWriter = null; try { Manifest mf = ma.getManifest(getSession(), getProject(), getArchive()); printWriter = new PrintWriter(WriterFactory.newWriter(manifestFile, WriterFactory.UTF_8)); mf.write(printWriter); } catch (ManifestException e) { throw new MojoExecutionException("Error preparing the manifest: " + e.getMessage(), e); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Error preparing the manifest: " + e.getMessage(), e); } catch (IOException e) { throw new MojoExecutionException("Error preparing the manifest: " + e.getMessage(), e); } finally { IOUtil.close(printWriter); } }
From source file:codes.writeonce.maven.plugins.soy.CompileMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { try {// ww w. ja v a2s. c o m process(); } catch (MojoExecutionException e) { throw e; } catch (Exception e) { getLog().error(e.getMessage()); throw new MojoExecutionException("Error compiling templates: " + e.getMessage(), e); } }
From source file:codes.writeonce.maven.plugins.soy.ExtractMessagesMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { try {/*from w ww . j a v a2s. c o m*/ process(); } catch (MojoExecutionException e) { throw e; } catch (Exception e) { getLog().error(e.getMessage()); throw new MojoExecutionException("Error extracting messages: " + e.getMessage(), e); } }
From source file:codesketch.scriba.maven.ScribaMojo.java
License:Apache License
private void writeResultDocumentToFileSystem(String data) throws MojoExecutionException { Writer writer = null;/*from ww w . ja v a 2s. co m*/ try { writer = WriterFactory.newPlatformWriter(getOutputFile()); writer.write(data); } catch (IOException e) { throw new MojoExecutionException("can't write results", e); } finally { closeSilently(writer); } }
From source file:codesketch.scriba.maven.ScribaMojo.java
License:Apache License
private List<Class<?>> interfaces() throws MojoExecutionException { List<Class<?>> classes = new ArrayList<>(); getLog().debug(String.format("defined interfaces %s", interfaces)); for (String iface : interfaces) { try {//from w w w . j a v a 2 s . co m getLog().debug(String.format("loading interface %s", iface)); classes.add(Class.forName(iface, false, getClassLoader())); } catch (ClassNotFoundException e) { throw new MojoExecutionException(String.format("class %s not found", iface), e); } } return classes; }
From source file:codesketch.scriba.maven.ScribaMojo.java
License:Apache License
private ClassLoader getClassLoader() throws MojoExecutionException { try {/*from w w w. j a v a 2s.co m*/ List<String> classpathElements = project.getCompileClasspathElements(); classpathElements.add(project.getBuild().getOutputDirectory()); classpathElements.add(project.getBuild().getTestOutputDirectory()); URL urls[] = new URL[classpathElements.size()]; for (int i = 0; i < classpathElements.size(); ++i) { urls[i] = new File(classpathElements.get(i)).toURI().toURL(); } return new URLClassLoader(urls, getClass().getClassLoader()); } catch (Exception e) { throw new MojoExecutionException("Couldn't create a classloader.", e); } }
From source file:codesketch.scriba.maven.writer.HttpWriter.java
License:Apache License
@Override public void write(String data) throws MojoExecutionException { try {/* w w w .j av a 2 s .c o m*/ String accessToken = null; if (useApiKey) { accessToken = this.apiKey; } else { accessToken = getAccessToken(); } this.logger.debug(format("token: %s", accessToken)); this.logger.info(format("authentication performed, sending %s to the server", data)); HttpResponse<JsonNode> putDocumentResponse = Unirest.put(targetUrl.toExternalForm()) .header("Authorization", format("ApiKey %s", accessToken)).body(data).asJson(); this.logger.info(putDocumentResponse.getBody().toString()); } catch (UnirestException e) { throw new MojoExecutionException(format("can't send results to remote host [%s]", targetUrl), e); } finally { this.shutdownSilently(); } }
From source file:com.abiquo.maven.plugins.redis.CleanMojo.java
License:Open Source License
/** * Cleans the Redis database./*from w w w .j a va 2s . c o m*/ * * @throws MojoExecutionException If there is an error during plugin execution, * @throws MojoFailureException If there is an error during plugin execution, */ @Override public void execute() throws MojoExecutionException, MojoFailureException { if (!skip) { initialize(); if (redis.ping()) { try { getLog().info("Cleaning the selected Redis database"); redis.flushDB(); } catch (IOException ex) { throw new MojoExecutionException("Could not clean the selected database: " + ex.getMessage(), ex); } } else { getLog().warn("Redis database seems to be down. Database clean will not be performed"); } } else { getLog().info("Skipping execution"); } }