in src/main/java/org/apache/maven/plugins/acr/AcrMojo.java [175:262]
public void execute() throws MojoExecutionException {
if (getLog().isInfoEnabled()) {
getLog().info("Building JavaEE Application client: " + jarName);
}
File jarFile = getAppClientJarFile(basedir, jarName);
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
archiver.setCreatedBy("Maven ACR Plugin", "org.apache.maven.plugins", "maven-acr-plugin");
archiver.setOutputFile(jarFile);
// configure for Reproducible Builds based on outputTimestamp value
archiver.configureReproducibleBuild(outputTimestamp);
try {
String[] mainJarExcludes = DEFAULT_EXCLUDES;
if (excludes != null && !excludes.isEmpty()) {
excludes.add(APP_CLIENT_XML);
mainJarExcludes = excludes.toArray(new String[0]);
}
if (outputDirectory.exists()) {
archiver.getArchiver().addDirectory(outputDirectory, DEFAULT_INCLUDES, mainJarExcludes);
} else {
// CHECKSTYLE_OFF: LineLength
getLog().info(
"JAR will only contain the META-INF/application-client.xml as no content was marked for inclusion");
// CHECKSTYLE_ON: LineLength
}
File deploymentDescriptor = new File(outputDirectory, APP_CLIENT_XML);
if (deploymentDescriptor.exists()) {
if (filterDeploymentDescriptor) {
getLog().debug("Filtering deployment descriptor.");
MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution();
mavenResourcesExecution.setEscapeString(escapeString);
List<FilterWrapper> filterWrappers = mavenFileFilter.getDefaultFilterWrappers(
project, filters, escapeBackslashesInFilePath, this.session, mavenResourcesExecution);
// Create a temporary file that we can copy-and-filter
File unfilteredDeploymentDescriptor = new File(outputDirectory, APP_CLIENT_XML + ".unfiltered");
FileUtils.copyFile(deploymentDescriptor, unfilteredDeploymentDescriptor);
mavenFileFilter.copyFile(
unfilteredDeploymentDescriptor,
deploymentDescriptor,
true,
filterWrappers,
getEncoding(unfilteredDeploymentDescriptor.toPath()));
// Remove the temporary file
FileUtils.forceDelete(unfilteredDeploymentDescriptor);
}
archiver.getArchiver().addFile(deploymentDescriptor, APP_CLIENT_XML);
}
// create archive
archiver.createArchive(session, project, archive);
// CHECKSTYLE_OFF: LineLength
} catch (ArchiverException e) {
throw new MojoExecutionException(
"There was a problem creating the JavaEE Application Client archive: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException(
"There was a problem reading / creating the manifest for the JavaEE Application Client archive: "
+ e.getMessage(),
e);
} catch (IOException e) {
throw new MojoExecutionException(
"There was a I/O problem creating the JavaEE Application Client archive: " + e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException(
"There was a problem resolving dependencies while creating the JavaEE Application Client archive: "
+ e.getMessage(),
e);
} catch (MavenFilteringException e) {
throw new MojoExecutionException(
"There was a problem filtering the deployment descriptor: " + e.getMessage(), e);
}
project.getArtifact().setFile(jarFile);
// CHECKSTYLE_ON: LineLength
}