Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top