Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i version a java application between builds?

Currently, my Java applications have the same version on every build. I am using Maven, but I am not sure how to set up the workflow to add a version to the application on each build.

I imagine this works with my version control system? I am using git, does this mean I need git tags?

Thanks for any insights, I know it's a big question, but I am not sure where to get started.

like image 903
Zippy Zeppoli Avatar asked Oct 31 '12 00:10

Zippy Zeppoli


People also ask

Can you have 2 different Java versions?

Yes, you can run multiple JVM's on a single machine.

Can I have different versions of Java?

If your application runs in a web browser using Java's browser plugin, you can only have one version at a time. Ignition does not use Java's browser plugin so you can continue using an older version. It is easy to specify which Java version you want to use when running Ignition's client.

How do I find the build version in Java?

Open a command prompt (Click Start > Run and type cmd). Use jre at the command prompt. This will return the Java JRE version number that is found in your path. Use java -version at the command prompt to check the version of the JDK in your path.


2 Answers

You start by setting your version to, for example, 1-SNAPSHOT.

Then you use the maven-release-plugin to release early and often.

In the interim, each snapshot gets a unique timestamp.

If you want to apply a version that isn't the official maven version, see the buildnumber-maven-plugin.

like image 167
bmargulies Avatar answered Oct 22 '22 12:10

bmargulies


I use this Maven plugin:

https://github.com/ktoso/maven-git-commit-id-plugin

and get it to generate a git.properties file for me. This includes the commit id, comments, etc.

From there, you can do whatever you like. I have a properties page in my webapp that simply iterates over everything in git.properties. Works for me.

like image 20
millhouse Avatar answered Oct 22 '22 12:10

millhouse