tags:

views:

68

answers:

1

Hi All,

In a pom.xml, if we are trying to compile and create a JAR, the name will be taken as

<artifactId>-<version>.jar

Is there a property or setting which can change the default separator '-' to something else?

I know that we can rename it after a jar has been created (or by using finalName). I was just wondering whether anyone else has tried this and had success.

Thanks a lot in advance!

+7  A: 

I don't know of a means to change the separator. But you can set the finalName element on your pom so that the jar is output to the target directory with that name. For example:

<build>
  ...
  <finalName>${project.artifactId}_${project.version}</finalName>
  <!--this is the default value
  <finalName>${artifactId}-${version}</finalName-->
  ...

It's worth noting that the artifact will still be installed/deployed to the repository with the default name, regardless of what you set in the finalName element.

As Pascal commented, allowing the conventions to be overridden for installed/deployed artifacts would cause problems for the dependency mechanism (it might still work, but the benefits of convention would be lost), so any benefits in flexibility would be outweighed by increased configuration verbosity and complexity - it's quite complex enough thanks.

Rich Seller
Thanks that was helpful. I was wondering about a way without using copy or finalName.
Aviator
You could use an assembly to create an additional jar, you'd just end up having to specify the finalName element in the assembly configuration though. See http://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html
Rich Seller
It's a good thing that the artifact is still installed/deployed to the repository with the default name or it would break the dependency resolution mechanism. TBH, I don't see the point of changing this convention...
Pascal Thivent
@RichSeller,@Pascal T:Thanks a lot! I see now why they have not provided a mechanism for that.:)
Aviator