Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version in jar name

When I import mvn project into Intellij the jar file it generates doesn't include version. But mvn generated jar has name-version.jar format. So I end up with two jar files one with version and another without one. I can of course, change module name in Intellij settings to include version. But that will be reset whenever I change pom file.

Maybe somebody else had a better idea?

like image 1000
husayt Avatar asked Dec 27 '22 02:12

husayt


1 Answers

The jar name that Maven generates on disk is controlled by /project/build/finalName so if you edit your pom.xml to look like

<project>
  ...
  <build>
    ...
    <finalName>${artifactId}</finalName>
    ...
  </build>
  ...
</project>

and then Maven will be generating the jar file without the version.

Note

finalName only controls the name of the file on disk. Once that file is transferred into the local repository cache or a remote repository it will be renamed to match the repository layout (i.e. ${artifactId}-${version}.${type} or ${artifactId}-${version}-${classifier}.${type} for artifacts with a classifier). You cannot change the format used by the repository.

I add the above note because the first thing everyone seems to want to do upon learning about the finalName parameter is try and change the name in the repository.

like image 116
Stephen Connolly Avatar answered Jan 07 '23 08:01

Stephen Connolly