javamavenmaven-plugin-development

How to Get Maven Project Version From Java Method as Like at Pom


I can get some variable's values from my pom file i.e.:

${project.version}

and I am developing a custom maven plugin and I can set it with expressions however I don't want it. How can I get it in a Java method as like my pom file?

PS: System.getProperty("project.version") doesn't work, I should find a generic solution because I will use it at other things too i.e. getting bamboo build number etc.


Solution

  • I've created a properties file and indicated at my pom:

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