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:ch.ivyteam.ivy.maven.IarDeployMojo.java
License:Apache License
private File copyIarToEngine(File deployDir) throws MojoExecutionException { File deployApp = new File(deployDir, deployToEngineApplication); File targetIarFile = new File(deployApp, deployIarFile.getName()); try {//w ww . j ava 2 s. c om getLog().info("Uploading project " + targetIarFile); FileUtils.copyFile(deployIarFile, targetIarFile); return targetIarFile; } catch (IOException ex) { throw new MojoExecutionException("Upload of IAR '" + deployIarFile.getName() + "' failed.", ex); } }
From source file:ch.ivyteam.ivy.maven.IarPackagingMojo.java
License:Apache License
private void createIvyArchive(File sourceDir, File targetIar) throws MojoExecutionException { ZipArchiver archiver = new ZipArchiver(); archiver.setDestFile(targetIar);/*w w w . jav a 2 s .co m*/ archiver.addFileSet(getDefaultFileset(sourceDir)); FileSetConverter fsConverter = new FileSetConverter(project.getBasedir()); for (org.codehaus.plexus.archiver.FileSet fs : fsConverter.toPlexusFileSets(iarFileSets)) { archiver.addFileSet(fs); } try { archiver.createArchive(); } catch (ArchiverException | IOException ex) { throw new MojoExecutionException("Failed to create IAR: " + targetIar.getAbsolutePath(), ex); } }
From source file:ch.ivyteam.ivy.maven.InstallEngineMojo.java
License:Apache License
private void removeOldEngineContent() throws MojoExecutionException { try {/*from w ww . ja va 2 s .c om*/ FileUtils.cleanDirectory(getRawEngineDirectory()); } catch (IOException ex) { throw new MojoExecutionException( "Failed to clean outdated ivy Engine directory '" + getRawEngineDirectory() + "'.", ex); } }
From source file:ch.ivyteam.ivy.maven.InstallEngineMojo.java
License:Apache License
private void unpackEngine(File downloadZip) throws MojoExecutionException { try {/*from w w w. j ava 2 s . c o m*/ String targetLocation = getRawEngineDirectory().getAbsolutePath(); getLog().info("Unpacking engine " + downloadZip.getAbsolutePath() + " to " + targetLocation); ZipFile engineZip = new ZipFile(downloadZip); engineZip.extractAll(targetLocation); } catch (ZipException ex) { throw new MojoExecutionException("Failed to unpack downloaded engine '" + downloadZip + "'.", ex); } }
From source file:ch.ivyteam.ivy.maven.StartTestEngineMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (skipTest) { getLog().info("Skipping start of engine."); return;/*from w w w . ja v a2s .co m*/ } try { startEngine(); } catch (Exception ex) { throw new MojoExecutionException("Cannot start engine", ex); } }
From source file:ch.ivyteam.ivy.maven.StopTestEngineMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (skipTest) { getLog().info("Skipping stop of engine."); return;// ww w. j a v a 2 s . c o m } try { createEngineController().stop(); } catch (Exception ex) { throw new MojoExecutionException("Cannot Stop engine", ex); } }
From source file:ch.ledcom.maven.sitespeed.SiteSpeedMojo.java
License:Apache License
/** * Main Mojo method./*from w ww. ja v a2 s .c om*/ * * @throws MojoExecutionException * in case of execution error * @throws MojoFailureException * in case of execution failure */ @Override public final void execute() throws MojoExecutionException, MojoFailureException { logParameters(); Properties mergerProperties = new Properties(); try { mergerProperties.load(this.getClass().getClassLoader().getResourceAsStream("merger.properties")); Injector injector = Guice.createInjector( // new SiteSpeedModule( // phantomJSPath, // verifyUrl, // crawlDepth, // "", // "", // proxy, // proxyType, // "", // ruleset, // "/report/velocity/page.vm", // userAgent, // viewport, // url, // mergerProperties, // outputDir, // getLog()), // new CrawlModule()); // SiteSpeedOrchestrator orchestrator = injector // .getInstance(SiteSpeedOrchestrator.class); SiteSpeedSingleThreadedOrchestrator orchestrator = injector .getInstance(SiteSpeedSingleThreadedOrchestrator.class); orchestrator.siteSpeed(); } catch (IOException e) { throw new MojoExecutionException("Could not execute sitespeed.", e); } }
From source file:ch.qos.cal10n.plugins.VerifyMojo.java
License:Open Source License
IMessageKeyVerifier getMessageKeyVerifierInstance(String enumClassAsStr) throws MojoExecutionException { String errMsg = "Failed to instantiate MessageKeyVerifier class"; try {/*from w ww . ja v a2s . c o m*/ ThisFirstClassLoader thisFirstClassLoader = (ThisFirstClassLoader) buildClassLoader(); Class<?> mkvClass = Class.forName(CAL10NConstants.MessageKeyVerifier_FQCN, true, thisFirstClassLoader); Constructor<?> mkvCons = mkvClass.getConstructor(String.class); IMessageKeyVerifier imcv = (IMessageKeyVerifier) mkvCons.newInstance(enumClassAsStr); return imcv; } catch (ClassNotFoundException e) { throw new MojoExecutionException(errMsg, e); } catch (NoClassDefFoundError e) { throw new MojoExecutionException(errMsg, e); } catch (Exception e) { throw new MojoExecutionException(errMsg, e); } }
From source file:ch.rasc.embeddedtc.plugin.PackageTcWarMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException { Path warExecFile = Paths.get(buildDirectory, finalName); try {/* www . ja v a2 s . co m*/ Files.deleteIfExists(warExecFile); Files.createDirectories(warExecFile.getParent()); try (OutputStream os = Files.newOutputStream(warExecFile); ArchiveOutputStream aos = new ArchiveStreamFactory() .createArchiveOutputStream(ArchiveStreamFactory.JAR, os)) { // If project is a war project add the war to the project if ("war".equalsIgnoreCase(project.getPackaging())) { File projectArtifact = project.getArtifact().getFile(); if (projectArtifact != null && Files.exists(projectArtifact.toPath())) { aos.putArchiveEntry(new JarArchiveEntry(projectArtifact.getName())); try (InputStream is = Files.newInputStream(projectArtifact.toPath())) { IOUtils.copy(is, aos); } aos.closeArchiveEntry(); } } // Add extraWars into the jar if (extraWars != null) { for (Dependency extraWarDependency : extraWars) { ArtifactRequest request = new ArtifactRequest(); request.setArtifact(new DefaultArtifact(extraWarDependency.getGroupId(), extraWarDependency.getArtifactId(), extraWarDependency.getType(), extraWarDependency.getVersion())); request.setRepositories(projectRepos); ArtifactResult result; try { result = repoSystem.resolveArtifact(repoSession, request); } catch (ArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } File extraWarFile = result.getArtifact().getFile(); aos.putArchiveEntry(new JarArchiveEntry(extraWarFile.getName())); try (InputStream is = Files.newInputStream(extraWarFile.toPath())) { IOUtils.copy(is, aos); } aos.closeArchiveEntry(); } } // Add extraResources into the jar. Folder /extra if (extraResources != null) { for (Resource extraResource : extraResources) { DirectoryScanner directoryScanner = new DirectoryScanner(); directoryScanner.setBasedir(extraResource.getDirectory()); directoryScanner.setExcludes(extraResource.getExcludes() .toArray(new String[extraResource.getExcludes().size()])); if (!extraResource.getIncludes().isEmpty()) { directoryScanner.setIncludes(extraResource.getIncludes() .toArray(new String[extraResource.getIncludes().size()])); } else { // include everything by default directoryScanner.setIncludes(new String[] { "**" }); } directoryScanner.scan(); for (String includeFile : directoryScanner.getIncludedFiles()) { aos.putArchiveEntry( new JarArchiveEntry(Runner.EXTRA_RESOURCES_DIR + "/" + includeFile)); Path extraFile = Paths.get(extraResource.getDirectory(), includeFile); try (InputStream is = Files.newInputStream(extraFile)) { IOUtils.copy(is, aos); } aos.closeArchiveEntry(); } } } Set<String> includeArtifacts = new HashSet<>(); includeArtifacts.add("org.apache.tomcat:tomcat-jdbc"); includeArtifacts.add("org.apache.tomcat.embed:tomcat-embed-core"); includeArtifacts.add("org.apache.tomcat.embed:tomcat-embed-logging-juli"); includeArtifacts.add("org.yaml:snakeyaml"); includeArtifacts.add("com.beust:jcommander"); if (includeJSPSupport) { includeArtifacts.add("org.apache.tomcat.embed:tomcat-embed-jasper"); includeArtifacts.add("org.eclipse.jdt.core.compiler:ecj"); } for (Artifact pluginArtifact : pluginArtifacts) { String artifactName = pluginArtifact.getGroupId() + ":" + pluginArtifact.getArtifactId(); if (includeArtifacts.contains(artifactName)) { try (JarFile jarFile = new JarFile(pluginArtifact.getFile())) { extractJarToArchive(jarFile, aos); } } } if (extraDependencies != null) { for (Dependency dependency : extraDependencies) { ArtifactRequest request = new ArtifactRequest(); request.setArtifact(new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), dependency.getVersion())); request.setRepositories(projectRepos); ArtifactResult result; try { result = repoSystem.resolveArtifact(repoSession, request); } catch (ArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } try (JarFile jarFile = new JarFile(result.getArtifact().getFile())) { extractJarToArchive(jarFile, aos); } } } if (includeJSPSupport) { addFile(aos, "/conf/web.xml", "conf/web.xml"); } else { addFile(aos, "/conf/web_wo_jsp.xml", "conf/web.xml"); } addFile(aos, "/conf/logging.properties", "conf/logging.properties"); if (includeTcNativeWin32 != null) { aos.putArchiveEntry(new JarArchiveEntry("tcnative-1.dll.32")); Files.copy(Paths.get(includeTcNativeWin32), aos); aos.closeArchiveEntry(); } if (includeTcNativeWin64 != null) { aos.putArchiveEntry(new JarArchiveEntry("tcnative-1.dll.64")); Files.copy(Paths.get(includeTcNativeWin64), aos); aos.closeArchiveEntry(); } String[] runnerClasses = { "ch.rasc.embeddedtc.runner.CheckConfig$CheckConfigOptions", "ch.rasc.embeddedtc.runner.CheckConfig", "ch.rasc.embeddedtc.runner.Config", "ch.rasc.embeddedtc.runner.Shutdown", "ch.rasc.embeddedtc.runner.Context", "ch.rasc.embeddedtc.runner.DeleteDirectory", "ch.rasc.embeddedtc.runner.ObfuscateUtil$ObfuscateOptions", "ch.rasc.embeddedtc.runner.ObfuscateUtil", "ch.rasc.embeddedtc.runner.Runner$1", "ch.rasc.embeddedtc.runner.Runner$2", "ch.rasc.embeddedtc.runner.Runner$StartOptions", "ch.rasc.embeddedtc.runner.Runner$StopOptions", "ch.rasc.embeddedtc.runner.Runner$RunnerShutdownHook", "ch.rasc.embeddedtc.runner.Runner" }; for (String rc : runnerClasses) { String classAsPath = rc.replace('.', '/') + ".class"; try (InputStream is = getClass().getResourceAsStream("/" + classAsPath)) { aos.putArchiveEntry(new JarArchiveEntry(classAsPath)); IOUtils.copy(is, aos); aos.closeArchiveEntry(); } } Manifest manifest = new Manifest(); Manifest.Attribute mainClassAtt = new Manifest.Attribute(); mainClassAtt.setName("Main-Class"); mainClassAtt.setValue(Runner.class.getName()); manifest.addConfiguredAttribute(mainClassAtt); aos.putArchiveEntry(new JarArchiveEntry("META-INF/MANIFEST.MF")); manifest.write(aos); aos.closeArchiveEntry(); aos.putArchiveEntry(new JarArchiveEntry(Runner.TIMESTAMP_FILENAME)); aos.write(String.valueOf(System.currentTimeMillis()).getBytes(StandardCharsets.UTF_8)); aos.closeArchiveEntry(); } } catch (IOException | ArchiveException | ManifestException e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:ch.sourcepond.maven.plugin.jenkins.config.ConfigBuilderImpl.java
License:Apache License
@Override public ConfigBuilder setJenkinscliDirectory(final Path pWorkDirectory) throws MojoExecutionException { config.setJenkinscliDirectory(pWorkDirectory); try {/*w w w .ja v a 2 s . c o m*/ createDirectories(pWorkDirectory); } catch (final IOException e) { throw new MojoExecutionException(e.getMessage(), e); } return this; }