Search code examples
javamavenquarkusmicroprofile

Quarkus / microprofile read pom.xml property


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?


Solution

  • 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;