in src/main/java/org/apache/maven/plugins/rar/RarMojo.java [332:409]
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Skipping rar generation.");
return;
}
// Check if jar file is there and if requested, copy it
try {
if (includeJar) {
File generatedJarFile = new File(outputDirectory, finalName + ".jar");
if (generatedJarFile.exists()) {
getLog().info("Including generated jar file[" + generatedJarFile.getName() + "]");
FileUtils.copyFileToDirectory(generatedJarFile, getBuildDir());
}
}
} catch (IOException e) {
throw new MojoExecutionException("Error copying generated Jar file", e);
}
// Copy dependencies
try {
Set<Artifact> artifacts = project.getArtifacts();
for (Artifact artifact : artifacts) {
ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
if (!artifact.isOptional()
&& filter.include(artifact)
&& artifact.getArtifactHandler().isAddedToClasspath()) {
getLog().info("Copying artifact[" + artifact.getGroupId() + ", " + artifact.getId() + ", "
+ artifact.getScope() + "]");
FileUtils.copyFileToDirectory(artifact.getFile(), getBuildDir());
}
}
} catch (IOException e) {
throw new MojoExecutionException("Error copying RAR dependencies", e);
}
resourceHandling();
// Include custom manifest if necessary
try {
includeCustomRaXmlFile();
} catch (IOException e) {
throw new MojoExecutionException("Error copying ra.xml file", e);
}
// Check if connector deployment descriptor is there
File ddFile = new File(getBuildDir(), RA_XML_URI);
if (!ddFile.exists() && warnOnMissingRaXml) {
getLog().warn("Connector deployment descriptor: " + ddFile.getAbsolutePath() + " does not exist.");
}
File rarFile = getRarFile(outputDirectory, finalName, classifier);
try {
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
archiver.setCreatedBy("Maven RAR Plugin", "org.apache.maven.plugins", "maven-rar-plugin");
archiver.setOutputFile(rarFile);
// configure for Reproducible Builds based on outputTimestamp value
archiver.configureReproducible(outputTimestamp);
// Include custom manifest if necessary
includeCustomManifestFile();
archiver.getArchiver().addDirectory(getBuildDir());
archiver.createArchive(session, project, archive);
} catch (Exception e) {
throw new MojoExecutionException("Error assembling RAR", e);
}
if (classifier != null) {
projectHelper.attachArtifact(project, "rar", classifier, rarFile);
} else {
project.getArtifact().setFile(rarFile);
}
}