Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Default Separator

Tags:

java

maven-2

jar

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!

like image 825
vpram86 Avatar asked Sep 16 '09 11:09

vpram86


1 Answers

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.

like image 184
Rich Seller Avatar answered Nov 15 '22 18:11

Rich Seller