You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by tc...@apache.org on 2013/10/31 08:46:37 UTC
svn commit: r1537397 -
/maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
Author: tchemit
Date: Thu Oct 31 07:46:36 2013
New Revision: 1537397
URL: http://svn.apache.org/r1537397
Log:
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)
Modified:
maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
Modified: maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java?rev=1537397&r1=1537396&r2=1537397&view=diff
==============================================================================
--- maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java (original)
+++ maven/plugins/trunk/maven-rar-plugin/src/main/java/org/apache/maven/plugin/rar/RarMojo.java Thu Oct 31 07:46:36 2013
@@ -33,6 +33,7 @@ import org.apache.maven.plugins.annotati
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 class RarMojo
{
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 @@ public class RarMojo
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.
*
- * @since 2.4
+ * If this is not given, it will merely be written to the output directory
+ * according to the finalName.
*
- * @parameter
+ * @since 2.4
*/
+ @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 @@ public class RarMojo
@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 @@ public class RarMojo
@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 @@ public class RarMojo
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 @@ public class RarMojo
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()