use of org.apache.maven.plugins.war.packaging.WarPostPackagingTask in project maven-plugins by apache.
the class AbstractWarMojo method buildWebapp.
/**
* Builds the webapp for the specified project with the new packaging task thingy.
* 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
*/
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, getDependentWarIncludes(), getDependentWarExcludes(), 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 these are NOT set, just use the defaults, which are '${*}' and '@'.
mavenResourcesExecution.setDelimiters(delimiters, useDefaultDelimiters);
if (nonFilteredFileExtensions != null) {
mavenResourcesExecution.setNonFilteredFileExtensions(nonFilteredFileExtensions);
}
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]");
}
Aggregations