1

I'm developing a JavaFX 8 application using IntelliJ, Maven and Git. I have an "about" window which shows the version number and build date. At the moment, I have to manually change these each time I update the code.

Is there any way I can have my build process automatically generate version and date information and embed this into my code so it shows up in the about window?

M. Teasdale
  • 323
  • 3
  • 17
  • 2
    Possible duplicate of [Retrieve version from maven pom.xml in code](http://stackoverflow.com/questions/3697449/retrieve-version-from-maven-pom-xml-in-code) – Arnaud Jan 18 '17 at 16:57
  • Also look at this one for the date part : http://stackoverflow.com/questions/13228472/how-to-acces-maven-build-timestamp-for-resource-filtering – Arnaud Jan 18 '17 at 16:58

1 Answers1

3

You can use maven resource filtering.

Prepare file eg. src/main/resources/version.properties with content:

version=${project.version}

and add in your pom:

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
...
<build>

After build maven replace ${project.version} for current project version.

In your project you can read this file and use in your abut window.

Read more about build timestamp property: How to access maven.build.timestamp for resource filtering

Community
  • 1
  • 1
Slawomir Jaranowski
  • 7,381
  • 3
  • 25
  • 33