We are trying to get the application version from maven pom.xml file and dynamically deciding where some documents are located.
For example, if the application version is 1.5, the documents may be in version1.5/application/
and so on.
The problem with getting version directly from pom.xml is , if application version is a snapshot, it will return 1.5.0-SNAPSHOT
. This is a problem.
For now we have solved it by taking a substring of the first three characters.
This way of solving the problem might create problems in the future if, say, application version is 1.11.
Is there any way we can get just the major and minor version, without the snapshot thing in maven ?
For example,
- if the maven version is 1.5.0-SNAPSHOT, I want 1.5
- if the maven version is 1.5.1, I still want just 1.5
- if the maven version is 1.12.1, I want just 1.12