1

I have configured the maven-jar-plugin as follow:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>2.3.2</version>
  <configuration>
    <finalName>${project.artifactId}.main</finalName>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>test-jar</goal>
      </goals>
      <configuration>
        <finalName>${project.artifactId}.tests</finalName>
      </configuration>
    </execution>
  </executions>
</plugin>

I want my output JAR files to be called ARTIFACT.main.jar and ARTIFACT.tests.jar. The former is working, but the later comes out as ARTIFACT.tests-tests.jar instead. Is there any way to adjust the above configuration to remove the -tests classifier?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Simon Kissane
  • 4,373
  • 3
  • 34
  • 59
  • The finalName is only working for the target folder and will not working if you deploy artifacts to a repository. Apart from that this is a naming schema. – khmarbaise Sep 22 '15 at 09:28
  • An other question is: Why do you like to name them different? Special purpose for this? – khmarbaise Sep 22 '15 at 09:42
  • @khmarbaise to be honest I just didn't like the look of it. I realise that deviating from conventions simply due to aesthetic preference is not a good idea, but this is just for my own learning, not use in anger – Simon Kissane Sep 23 '15 at 10:44
  • Thanks for the feedback i just wanted to know if you might have other reasons to go that way... – khmarbaise Sep 23 '15 at 12:40

1 Answers1

1

Unfortunately, after looking at the maven-jar-plugin source code, I don't think it is possible to remove the tests classifier from the test jar.

The execute method that is called during the goal test-jar takes the output of the method getClassifier() to append a classifier:

File jarFile = createArchive();
String classifier = getClassifier();
if ( classifier != null )
{
    projectHelper.attachArtifact( getProject(), getType(), classifier, jarFile );
}
else
{
    getProject().getArtifact().setFile( jarFile );
}

and the getClassifier() method returns the hard-coded String "tests" for the test-jar goal.

I found an "Improvement" (MJAR-199) in the maven-jar-plugin JIRA about this. Feel free to vote for it!

Tunaki
  • 132,869
  • 46
  • 340
  • 423