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

[jira] [Updated] (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:all-tabpanel ]

Karl Heinz Marbaise updated MJAR-177:
-------------------------------------
    Fix Version/s: 3.0.0

> 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
>             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)