MRAR-28 - Add Support for Classifier
o Use java 1.5 annotation
o Fix java documentation (+ make it as told a simple atached file if classifer is used)
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1537397 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/plugin/rar/RarMojo.java b/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
index 23c6961..0b51f73 100644
--- a/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
@@ -33,6 +33,7 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
import org.apache.maven.shared.filtering.MavenFilteringException;
import org.apache.maven.shared.filtering.MavenResourcesExecution;
import org.apache.maven.shared.filtering.MavenResourcesFiltering;
@@ -61,8 +62,6 @@
{
public static final String RA_XML_URI = "META-INF/ra.xml";
- private static final String[] DEFAULT_INCLUDES = { "**/**" };
-
/**
* Single directory for extra files to include in the RAR.
*/
@@ -107,27 +106,17 @@
private String finalName;
/**
- * The maven project.
- */
- @Component
- private MavenProject project;
-
- /**
- * Classifier to add to the artifact generated. If given, the artifact will be an attachment instead.
+ * Classifier to add to the artifact generated. If given, the artifact will be attached.
+ *
+ * If this is not given, it will merely be written to the output directory
+ * according to the finalName.
*
* @since 2.4
- *
- * @parameter
*/
+ @Parameter( property = "maven.rar.classifier", defaultValue = "" )
private String classifier;
/**
- * The Jar archiver.
- */
- @Component( role = Archiver.class, hint = "jar" )
- private JarArchiver jarArchiver;
-
- /**
* The archive configuration to use.
* See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven Archiver Reference</a>.
*/
@@ -142,13 +131,6 @@
@Parameter( property = "rar.filterRarSourceDirectory", defaultValue = "false" )
private boolean filterRarSourceDirectory;
-
- /**
- * @since 2.3
- */
- @Component( role = MavenResourcesFiltering.class, hint = "default" )
- protected MavenResourcesFiltering mavenResourcesFiltering;
-
/**
* @since 2.3
*/
@@ -282,6 +264,30 @@
@Parameter( property = "maven.rar.skip" )
private boolean skip;
+ /**
+ * The maven project.
+ */
+ @Component
+ private MavenProject project;
+
+ /**
+ * The Jar archiver.
+ */
+ @Component( role = Archiver.class, hint = "jar" )
+ private JarArchiver jarArchiver;
+
+ /**
+ * @since 2.3
+ */
+ @Component( role = MavenResourcesFiltering.class, hint = "default" )
+ protected MavenResourcesFiltering mavenResourcesFiltering;
+
+ /**
+ * @since 2.4
+ */
+ @Component
+ private MavenProjectHelper projectHelper;
+
private File buildDir;
@@ -427,9 +433,9 @@
getLog().warn( "Connector deployment descriptor: " + ddFile.getAbsolutePath() + " does not exist." );
}
+ File rarFile = getRarFile(outputDirectory, finalName, classifier);
try
{
- File rarFile = getRarFile(outputDirectory, finalName, classifier);
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver( jarArchiver );
archiver.setOutputFile( rarFile );
@@ -439,13 +445,20 @@
archiver.getArchiver().addDirectory( getBuildDir() );
archiver.createArchive( session, project, archive );
-
- project.getArtifact().setFile( rarFile );
}
catch ( Exception e )
{
throw new MojoExecutionException( "Error assembling RAR", e );
}
+
+ if ( classifier != null )
+ {
+ projectHelper.attachArtifact( project, "rar", classifier, rarFile );
+ }
+ else
+ {
+ project.getArtifact().setFile( rarFile );
+ }
}
protected File getBuildDir()