4

What i need to do is retrieve project version from pom.xml from java code.

I'm currently use the snippet as the official documentation suggests:

@ConfigProperty(name = "version")
public String version;

application.properties :

version=${quarkus.platform.version}

Therefore seems like pom.xml properties is not available through application.properties without any boilerplate. Any ideas?

tzou85
  • 43
  • 4

1 Answers1

4

Try this as i posted on: quarkus read pom.xml properties

pom.xml :

<resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/application.properties</include>
            </includes>
        </resource>
   </resources>

In application.properties use version property:

quarkus.version=${quarkus.platform.version}

Then use it as a config property:

@ConfigProperty(name = "quarkus.version")
String version;
  • Yes seems to work that way! Is there any quarkus specific way to do it so? – tzou85 Dec 19 '19 at 09:12
  • @tzou85 not sure about any quarkus specific way to do it so.. You can ping the quarkus guys for something like that – Spiros batzio Dec 19 '19 at 09:15
  • This is quite confusing, since the Quarkus documentation says that there is already a property defined to read the version, namely: quarkus.application.version, but this doesn't work either. See also: https://stackoverflow.com/questions/58306053/how-can-i-get-the-version-of-the-application-defined-by-tag-version-im-pom-in?r=SearchResults&s=12|59.3560 – Serkan Dec 22 '19 at 21:44