use of org.apache.maven.shared.utils.io.FileUtils.FilterWrapper in project maven-plugins by apache.
the class AcrMojo method execute.
/**
* {@inheritDoc}
*/
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.setOutputFile(jarFile);
try {
String[] mainJarExcludes = DEFAULT_EXCLUDES;
if (excludes != null && !excludes.isEmpty()) {
excludes.add(APP_CLIENT_XML);
mainJarExcludes = excludes.toArray(new String[excludes.size()]);
}
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));
// 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
}
use of org.apache.maven.shared.utils.io.FileUtils.FilterWrapper in project maven-plugins by apache.
the class EjbMojo method filterDeploymentDescriptor.
private void filterDeploymentDescriptor(File deploymentDescriptor) throws MavenFilteringException, IOException {
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(sourceDirectory, ejbJar + ".unfiltered");
FileUtils.copyFile(deploymentDescriptor, unfilteredDeploymentDescriptor);
mavenFileFilter.copyFile(unfilteredDeploymentDescriptor, deploymentDescriptor, true, filterWrappers, getEncoding(unfilteredDeploymentDescriptor));
// Remove the temporary file
FileUtils.forceDelete(unfilteredDeploymentDescriptor);
}
Aggregations