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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With