Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I access the version information from the pom within the java code?

 
Joerg Wesely
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have project using maven with a simple pom:

[...]
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>
[...]

is there a way to access the version information within my java code?
I'd like my program to display the version number from the pom it has been built with.

Is that possible?

Thanks in advance

Jörg
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jörg and welcome to Javaranch!

I'm not 100% sure if it's possible, is it perhaps accessible as a System Property?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the POM:


In the resource-filtered directory, file "version.txt":



This is just a "web page" I display for version verification to make sure that the proper system release is running. But it could have just as easily been a properties file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic