my dog learned polymorphism*
The moose likes Ant, Maven and Other Build Tools and the fly likes Can I access the version information from the pom within the java code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Can I access the version information from the pom within the java code?" Watch "Can I access the version information from the pom within the java code?" New topic
Author

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

Joerg Wesely
Greenhorn

Joined: Jan 15, 2010
Posts: 3
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Jörg and welcome to Javaranch!

I'm not 100% sure if it's possible, is it perhaps accessible as a System Property?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I access the version information from the pom within the java code?