You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Hudson (JIRA)" <ji...@apache.org> on 2015/12/18 19:13:46 UTC

[jira] [Commented] (MJAR-177) Empty string should be treated as default classifier

    [ https://issues.apache.org/jira/browse/MJAR-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15064384#comment-15064384 ] 

Hudson commented on MJAR-177:
-----------------------------

SUCCESS: Integrated in maven-plugins #4893 (See [https://builds.apache.org/job/maven-plugins/4893/])
[MJAR-177] Empty string should be treated as default classifier
 - The classifier will now correctly being checked against null
   and to contain more than white spaces. The default value for
   the classifier empty string has been removed. (khmarbaise: [http://svn.apache.org/viewvc/?view=rev&rev=1720830])
* maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
* maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/JarMojo.java
* maven-jar-plugin/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java


> Empty string should be treated as default classifier
> ----------------------------------------------------
>
>                 Key: MJAR-177
>                 URL: https://issues.apache.org/jira/browse/MJAR-177
>             Project: Maven JAR Plugin
>          Issue Type: Bug
>    Affects Versions: 2.4
>         Environment: $ mvn -version
> Apache Maven 3.0.4
> Maven home: /usr/share/maven
> Java version: 1.7.0_55, vendor: Oracle Corporation
> Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux", version: "3.11.0-14-generic", arch: "amd64", family: "unix"
>            Reporter: Stefan Fussenegger
>            Assignee: Karl Heinz Marbaise
>             Fix For: 3.0.0
>
>
> I'm not an expert for Maven internals, but there seem to be subtle differences regarding empty properties. Sometimes they are set to null and sometimes they remain an empty string (""). The later causes an error when used as classifier
> This seems to be the problematic code from AbstratJarMojo.java:
> {code:java}
> String classifier = getClassifier();
> if ( classifier != null ) // ERROR check for empty string
> {
>     projectHelper.attachArtifact( getProject(), getType(), classifier, jarFile );
> }
> else
> {
>     getProject().getArtifact().setFile( jarFile );
> }
> {code}
> The resulting error is
> {code}
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar (default-jar) on project sample-project: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar failed: For artifact {org.example:sample-project:1.0.0-SNAPSHOT:jar}: An attached artifact must have a different ID than its corresponding main artifact. -> [Help 1]
> {code}
> It's not easy to set a property to "" though as properties from XML will typically resolve to null but some plugins do. For example, it's possible to use gmaven-plugin to achieve this:
> {code:xml}
> <plugin>
>   <groupId>org.codehaus.gmaven</groupId>
>   <artifactId>gmaven-plugin</artifactId>
>   <executions>
>     <execution>
>       <id>artifact-classifier</id>
>       <phase>initialize</phase>
>       <goals>
>         <goal>execute</goal>
>       </goals>
>       <configuration>
>         <source>
>           project.properties['artifact.classifier'] = "";
>         </source>
>       </configuration>
>     </execution>
>   </executions>
> </plugin>
> <plugin>
>   <artifactId>maven-jar-plugin</artifactId>
>   <version>${maven-jar-plugin.version}</version>
>   <inherited>true</inherited>
>   <configuration>
>     <classifier>${artifact.classifier}</classifier>
>   </configuration>
> </plugin>
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)