How to build maven project without version

If you wanted to build maven project without the version details mentioned in your pom file, then you need to follow the below instructions.

Let’s say you have the pom.xml with following details

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.sneppets</groupId>
  <artifactId>MyService</artifactId>
  <version>2.0.0</version>
  <name>MyService</name>

  ----

  ----

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

  ----

  ----
    
</project>

You could see finalName within build tags of your pom file. By default, the finalName is ${artifactId}-${version} and this is the name of the bundled project once it is finally built (jar or war or ear).

Build Maven Project without version detail

For instance, if the bundled project has jar extension, then the final name of the built target file looks like MyService-2.0.0.jar and if you wanted to build the maven project without version in the final name, then you can change the name through <finalName> element as below

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

With the above changes, the final name of the file now looks like MyService.jar without version details. That’s it.

Further Learning

References

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments