Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically getting the Maven version of your project

Tags:

java

maven

How do I get the Maven version of my project programatically?

In other words:

static public String getVersion()
{
    ...what goes here?...
}

For example, if my project would generate the jar CalculatorApp-1.2.3.jar, I want getVersion() to return 1.2.3.

like image 973
Kevin Wong Avatar asked Jan 06 '12 21:01

Kevin Wong


People also ask

How do I find my Maven compiler version?

Before moving on, we can check the default JDK version of Maven. Running the mvn -v command will show the Java version in which Maven runs.

How do you get Pom properties at runtime?

Use the properties-maven-plugin to write specific pom properties to a file at compile time, and then read that file at run time.

What is version in Maven POM xml?

version. It is the sub element of project. It specifies the version of the artifact under given group. File: pom.xml.


1 Answers

For jar files, you have the MANIFEST.MF as the default place to put the Implementation-Version there. Maven supports building the jar file like this.

See also How do I add an Implementation-Version value to a jar manifest using Maven?

like image 68
Frischling Avatar answered Sep 27 '22 21:09

Frischling