use of org.apache.maven.artifact.factory.ArtifactFactory in project maven-plugins by apache.
the class ClassesPackagingTask method generateJarArchive.
/**
* @param context The warPackingContext.
* @throws MojoExecutionException In casae of an error.
*/
protected void generateJarArchive(WarPackagingContext context) throws MojoExecutionException {
MavenProject project = context.getProject();
ArtifactFactory factory = context.getArtifactFactory();
Artifact artifact = factory.createBuildArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "jar");
String archiveName;
try {
archiveName = getArtifactFinalName(context, artifact);
} catch (InterpolationException e) {
throw new MojoExecutionException("Could not get the final name of the artifact [" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + "]", e);
}
final String targetFilename = LIB_PATH + archiveName;
if (context.getWebappStructure().registerFile(currentProjectOverlay.getId(), targetFilename)) {
final File libDirectory = new File(context.getWebappDirectory(), LIB_PATH);
final File jarFile = new File(libDirectory, archiveName);
final ClassesPackager packager = new ClassesPackager();
packager.packageClasses(context.getClassesDirectory(), jarFile, context.getJarArchiver(), context.getSession(), project, context.getArchive());
} else {
context.getLog().warn("Could not generate archive classes file [" + targetFilename + "] has already been copied.");
}
}
Aggregations