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.sourcepond.maven.plugin.jenkins.config.ConfigBuilderImpl.java
License:Apache License
@Override public ConfigBuilder setBaseUrl(final URL pBaseUrl, final String pCliUri) throws MojoExecutionException { try {/* ww w. j a va2s. c om*/ config.setBaseUri(pBaseUrl.toURI()); final String cliPath = pCliUri.startsWith("/") ? pCliUri : "/" + pCliUri; config.setCliJarUri(new URL(pBaseUrl.toString() + cliPath).toURI()); } catch (final URISyntaxException | MalformedURLException e) { throw new MojoExecutionException(e.getMessage(), e); } return this; }
From source file:ch.sourcepond.maven.plugin.jenkins.process.ProcessExecutorFactoryImpl.java
License:Apache License
@Override public ProcessExecutor newExecutor(final Log pLog, final Config pConfig, final List<String> pCommand) throws MojoExecutionException { final ProcessExecutor executor = new ProcessExecutor(pCommand); final CloseStreamsListener listener = rosFactory.newListener(pLog); try {//from w w w . j a va 2s.c o m final OutputStream logOut = rosFactory.newLogRedirect(pLog); // stdout/stderr to log executor.redirectOutput(logOut); executor.redirectError(logOut); final OutputStream out = listener.setStdout(rosFactory.newStdout(pConfig)); // Stdout to file (if any) executor.redirectOutputAlsoTo(out); executor.redirectErrorAlsoTo(out); // Stdin executor.redirectInput(listener.setStdin(rosFactory.newStdin(pConfig))); } catch (final IOException e) { listener.closeAll(); throw new MojoExecutionException(e.getMessage(), e); } return executor.addListener(listener); }
From source file:ch.sourcepond.maven.plugin.jenkins.resolver.ArtifactFactoryImpl.java
License:Apache License
@Override public Artifact newArtifact(final String pCoords) throws MojoExecutionException { try {/* w w w .j ava 2s . c o m*/ return new DefaultArtifact(pCoords); } catch (final IllegalArgumentException e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:ch.sourcepond.maven.plugin.repobuilder.ArtifactCopier.java
License:Apache License
/** * Copies the original file specified to the copy path specified. If the * copy path already exists, it will be overwritten. * //from w w w.j a va 2 s . c o m * @param pOriginal * Path to copy; must be a file and not {@code null} * @param pCopy * Path where to copy the original file; must be non-existent or * must point to a file. Must not be {@code null}. * @throws MojoExecutionException * Thrown if an {@link IOException} occurred during copy. */ public void copyToDedicatedRepository(final Path pOriginal, final Path pCopy) throws MojoExecutionException { try { createDirectories(pCopy.getParent()); copy(pOriginal, pCopy, REPLACE_EXISTING); } catch (final IOException e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:ch.sourcepond.maven.plugin.repobuilder.RepositoryBuilderMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { try (final RootDirectory root = rootDirectoryFactory.createRoot(getLog(), outputDirectory, archiveType)) { final RepositorySwitch repositorySwitch = repositorySwitchFactory.createSwitch(root.getPath(), snapshotRepository, releaseRepository); for (final Artifact artifact : project.getArtifacts()) { copyToTarget(repositorySwitch, artifact); }/*from ww w. ja va2s .c o m*/ if (additionalArtifacts != null) { for (final AdditionalArtifact additionalArtifact : additionalArtifacts) { copyToTarget(repositorySwitch, additionalArtifact.toArtifact()); } } getLog().info("Written repository archive to " + root); } catch (final IOException e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:ch.sourcepond.maven.release.ReleaseInvoker.java
License:Apache License
final void setLocalMavenRepo(final File localMavenRepo) throws MojoExecutionException { if (localMavenRepo != null) { try {/* w ww . j av a 2 s . co m*/ request.setLocalRepositoryDirectory(localMavenRepo.getCanonicalFile()); } catch (final IOException e) { throw new MojoExecutionException("Local repository path could not be determined!", e); } } }
From source file:cn.dreampie.MinifierMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { LogKit.setLog(getLog());/* w w w. ja va 2 s .co m*/ try { getLog().info("Minifying all Javascript Files in the Output Directory"); ClosureMinifier minifier = new ClosureMinifier(); minifier.setSourceDirectory(sourceDirectory); List<File> filesToMinify; if (null != includeFiles) { filesToMinify = Lists.newArrayList(includeFiles); getLog().info("About to include the following files: " + FileUtilities.getCommaSeparatedListOfFileNames(filesToMinify)); } else { getLog().debug("No file to include,use sourceDirectory."); filesToMinify = FileUtilities.directoryToFileList(sourceDirectory); } List<File> filesToMinifyMinusDestFile = null; if (null != excludeFiles) { filesToMinifyMinusDestFile = getMinifyFiles(filesToMinify, Lists.newArrayList(excludeFiles)); } else { filesToMinifyMinusDestFile = filesToMinify; } if (filesToMinifyMinusDestFile != null && filesToMinifyMinusDestFile.size() > 0) { getLog().info("About to minify the following files: " + FileUtilities.getCommaSeparatedListOfFileNames(filesToMinifyMinusDestFile)); } else { getLog().info("No file to minify."); } if (merge) { minifier.compile(filesToMinifyMinusDestFile, outputFile); } else { minifier.setOutputDirectory(outputDirectory); minifier.compile(filesToMinifyMinusDestFile); } } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:cn.org.once.cstack.maven.plugin.mojo.CloudUnitDeployMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { connect();/*from w ww . j ava 2s.com*/ if (!isApplicationExists()) { if (createIfNotExists) { getLog().info("Initialize " + applicationName + " application"); try { create(); addModule(); deployApp(); } catch (CheckException e) { throw new MojoExecutionException( "Failed to initialize the application caused by " + e.getLocalizedMessage(), e); } } else { getLog().error( "This application does not exist. Please create them or launch build with createIfNotExists command"); throw new MojoExecutionException("Failed to deploy"); } } else { if (snapshotOnDeploy) { createSnapshot(); } deployApp(); } }
From source file:cn.wanghaomiao.maven.plugin.seimi.AbstractWarMojo.java
License:Apache License
/** * @param webapplicationDirectory The web application directory. * @throws MojoExecutionException In case of failure. * @throws MojoFailureException In case of failure. *///from w w w .j a v a 2s .c o m public void buildExplodedWebapp(File webapplicationDirectory) throws MojoExecutionException, MojoFailureException { webapplicationDirectory.mkdirs(); try { buildWebapp(project, webapplicationDirectory); } catch (IOException e) { throw new MojoExecutionException("Could not build webapp", e); } }
From source file:cn.wanghaomiao.maven.plugin.seimi.AbstractWarMojo.java
License:Apache License
/** * Builds the webapp for the specified project with the new packaging task thingy * <p/>// w ww . j a v a2 s . c om * Classes, libraries and tld files are copied to the <tt>webappDirectory</tt> during this phase. * * @param mavenProject the maven project * @param webapplicationDirectory the target directory * @throws MojoExecutionException if an error occurred while packaging the webapp * @throws MojoFailureException if an unexpected error occurred while packaging the webapp * @throws IOException if an error occurred while copying the files */ @SuppressWarnings("unchecked") public void buildWebapp(MavenProject mavenProject, File webapplicationDirectory) throws MojoExecutionException, MojoFailureException, IOException { WebappStructure cache; if (useCache && cacheFile.exists()) { // CHECKSTYLE_OFF: LineLength cache = new WebappStructure(mavenProject.getDependencies(), webappStructureSerialier.fromXml(cacheFile)); // CHECKSTYLE_ON: LineLength } else { cache = new WebappStructure(mavenProject.getDependencies(), null); } // CHECKSTYLE_OFF: LineLength final long startTime = System.currentTimeMillis(); getLog().info( "Assembling webapp [" + mavenProject.getArtifactId() + "] in [" + webapplicationDirectory + "]"); final OverlayManager overlayManager = new OverlayManager(overlays, mavenProject, dependentWarIncludes, dependentWarExcludes, currentProjectOverlay); final List<WarPackagingTask> packagingTasks = getPackagingTasks(overlayManager); // CHECKSTYLE_ON: LineLength List<FileUtils.FilterWrapper> defaultFilterWrappers; try { MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(); mavenResourcesExecution.setEscapeString(escapeString); mavenResourcesExecution.setSupportMultiLineFiltering(supportMultiLineFiltering); mavenResourcesExecution.setMavenProject(mavenProject); if (filters == null) { filters = getProject().getBuild().getFilters(); } mavenResourcesExecution.setFilters(filters); mavenResourcesExecution.setEscapedBackslashesInFilePath(escapedBackslashesInFilePath); mavenResourcesExecution.setMavenSession(this.session); mavenResourcesExecution.setEscapeString(this.escapeString); mavenResourcesExecution.setSupportMultiLineFiltering(supportMultiLineFiltering); defaultFilterWrappers = mavenFileFilter.getDefaultFilterWrappers(mavenResourcesExecution); } catch (MavenFilteringException e) { getLog().error("fail to build filering wrappers " + e.getMessage()); throw new MojoExecutionException(e.getMessage(), e); } final WarPackagingContext context = new DefaultWarPackagingContext(webapplicationDirectory, cache, overlayManager, defaultFilterWrappers, getNonFilteredFileExtensions(), filteringDeploymentDescriptors, this.artifactFactory, resourceEncoding, useJvmChmod); for (WarPackagingTask warPackagingTask : packagingTasks) { warPackagingTask.performPackaging(context); } // Post packaging final List<WarPostPackagingTask> postPackagingTasks = getPostPackagingTasks(); for (WarPostPackagingTask task : postPackagingTasks) { task.performPostPackaging(context); } getLog().info("Webapp assembled in [" + (System.currentTimeMillis() - startTime) + " msecs]"); }