Search code examples
javamavenmaven-plugin

Will maven re-read a pom file for different lifecycle phases?


I'm working on creating a maven plugin that will modify version numbers of dependencies in the current pom.xml file.

I can't seem to find any reference about whether maven will re-read the pom.xml file in between lifecycle phases, or whether I can force it to?

The alternative would be to invoke the plugin, and then call the build step after that - but I'd like to do it in one step if it's possible.

Thanks.


Solution

  • This is not possible.

    Maven reads the dependencies before invoking plugins, so you need to change the version numbers in a separate Maven run, like

    mvn versions:use-releases
    mvn clean install
    

    Running one command like

    mvn versions:use-releases clean install
    

    will not work.