Reputation: 11
I am new to the Maven. I am currently working on a Maven multi-module project. I want to execute the Maven lifecycle phases from a script file in Windows. I mean the requirement is like that when we run this script file then validate
, test
, compile
, package
, install
, deploy
theses phases should run automatically.
I also gone through the Maven goals in pom.xml
also the executor and assembler plugin.
But I am not able to get my solution. So how should I create the build script file for this in windows.
Upvotes: 0
Views: 270
Reputation: 14762
See Maven, Introduction to the Build Lifecycle:
These lifecycle phases (plus the other lifecycle phases not shown here) are executed sequentially to complete the
default
lifecycle. Given the lifecycle phases above, this means that when the default lifecycle is used, Maven will first validate the project, then will try to compile the sources, run those against the tests, package the binaries (e.g. jar), run integration tests against that package, verify the package, install the verifed package to the local repository, then deploy the installed package in a specified environment.To do all those, you only need to call the last build phase to be executed, in this case,
deploy
:mvn deploy
That is because if you call a build phase, it will execute not only that build phase, but also every build phase prior to the called build phase.
Long story short: If you invoke mvn deploy
in your script, all the phases you mention (and even more) are passed by Maven already by design.
Re „the Maven goals in pom.xml
“ – Maven and also POMs don't have goals in itself. You rather can bind goals (provided by plugins) to lifecycle phases in the latter. See Maven: Lifecycle vs. Phase vs. Plugin vs. Goal for an explanation what's it all about with these Maven terms.
Further reading:
Upvotes: 1