You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vm...@apache.org on 2006/10/09 21:40:44 UTC
svn commit: r454472 -
/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java
Author: vmassol
Date: Mon Oct 9 12:40:43 2006
New Revision: 454472
URL: http://svn.apache.org/viewvc?view=rev&rev=454472
Log:
MSOURCES-10: Attached source artifact should not be added for artifacts with classifier
Modified:
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java
Modified: maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java?view=diff&rev=454472&r1=454471&r2=454472
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarDefaultSourceMojo.java Mon Oct 9 12:40:43 2006
@@ -47,23 +47,34 @@
}
else
{
- File outputFile = new File( outputDirectory, finalName + "-sources.jar" );
- File[] sourceDirectories = getDefaultSources();
-
- try
- {
- createJar( outputFile, sourceDirectories, new JarArchiver() );
- }
- catch ( IOException e )
+ // Do not attach source JAR for artifacts with classifier. This is because Maven2 only supports a single
+ // classifier per artifact. This is a limitation. See http://jira.codehaus.org/browse/MSOURCES-10.
+ if ( getProject().getArtifact().getClassifier() != null )
{
- throw new MojoExecutionException( "Error creating source archive: " + e.getMessage(), e );
+ getLog().warn( "NOT adding sources to artifacts with classifier as Maven only supports one classifier "
+ + "per artifact. Current artifact [" + getProject().getArtifact().getId() + "] has a ["
+ + getProject().getArtifact().getClassifier() + "] classifier.");
}
- catch ( ArchiverException e )
+ else
{
- throw new MojoExecutionException( "Error creating source archive: " + e.getMessage(), e );
- }
+ File outputFile = new File( outputDirectory, finalName + "-sources.jar" );
+ File[] sourceDirectories = getDefaultSources();
+
+ try
+ {
+ createJar( outputFile, sourceDirectories, new JarArchiver() );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error creating source archive: " + e.getMessage(), e );
+ }
+ catch ( ArchiverException e )
+ {
+ throw new MojoExecutionException( "Error creating source archive: " + e.getMessage(), e );
+ }
- attachArtifact( outputFile, "sources" );
+ attachArtifact( outputFile, "sources" );
+ }
}
}