I'll just mention that I've used the file referenced in the StackOverflow
question, META-INF/maven/${groupId}/${artifactId}/pom.properties, before to
do something much like you describe, print my application version to the
log at startup.

It did not need any special configuration to appear, and only took a
handful of lines to getResourceAsStream(), load into a Properties object,
and ask pomProperties.getProperty("version","development"). 'development'
is a safety default here for when the project is running in a context
before being packaged, like testing.

Now, how does pom.properties get populated? Will it always be populated?
Will this still work in a Java 9+/JPMS/Maven 4+ world? Unspecified,
exercise for the reader.

Reply via email to