}
}
}
private void copyBaseArtifact() throws MojoExecutionException {
Artifact artifact = getBaseArtifact();
if (artifact == null) {
throw new MojoExecutionException(
String.format("Project doesn't have a base dependency of groupId %s and artifactId %s",
base.getGroupId(), base.getArtifactId()));
}
File destinationDir = new File(getOutputDirectory(), baseDestination);
File destinationFile = new File(destinationDir, artifact
.getArtifactId()
+ "." + artifact.getArtifactHandler().getExtension());
// check if custom sling.properties file or bootstrap command exists
final Properties additionalProps = this.getSlingProperties(JAR.equals(this.packaging));
final String bootstrapCmd = this.getSlingBootstrap(JAR.equals(this.packaging));
if ( additionalProps != null || bootstrapCmd != null ) {
// unpack to a temp destination
final File dest = new File(this.tempDirectory, "basejar");
try {
unpack(artifact.getFile(), dest);
// patch sling properties
if ( additionalProps != null ) {
this.patchSlingProperties(dest, additionalProps);
}
// patch bootstrap command
if ( bootstrapCmd != null ) {
this.patchSlingBootstrap(dest, bootstrapCmd);
}
// and repack again
pack(dest, destinationFile);
} finally {
this.tempDirectory.delete();
}
} else {
// we can just copy
if (shouldCopy(artifact.getFile(), destinationFile)) {
try {
getLog().info(
String.format("Copying base artifact from %s to %s.",
artifact.getFile(), destinationFile));
FileUtils.copyFile(artifact.getFile(), destinationFile);
} catch (IOException e) {
throw new MojoExecutionException(
"Unable to copy base artifact.", e);
}
} else {
getLog().debug(
String.format("Skipping copy of base artifact from %s.",
artifact.getFile()));
}
}
}