Reputation: 1
I have to perform following steps in my maven build, in the specific order mentioned below:
I have to use JDK 6, so using Maven 3.2.1.
In the pom file, I have defined 5 different profiles for #1, #2, #3, #4, #7 above (profile ids: p1, p2, p3, p4, p5). I am building my project using multiple commands:
The build works okay with multiple commands, but is it possible to execute all steps using one command i.e. mvn clean install ?
What I understand is, it is not possible to have multiple executions of exec-maven-plugin in non consecutive order, hence I used profiles and then execute each step using the profile id. Reference: Maven maven-exec-plugin multiple execution configurations
Upvotes: 0
Views: 1245
Reputation: 1638
What I understand is, it is not possible to have multiple executions of exec-maven-plugin in non consecutive order, hence I used profiles and then execute each step using the profile id.
The “profile trick” mentioned elsewhere is only needed when performing explicit goal invocation from the command line.
From what I gather, however, you would rather have your goals executed as part of a normal mvn clean install
. In that case, you are in luck: Simply bind each goal to an appropriate phase in the default lifecycle. Depending on what your steps do, you may, e.g., bind the first <execution>
of exec:exec
(step 1) to the generate-sources
phase. If the first <execution>
of antrun:antrun
(step 2) is then bound to, say, the process-sources
phase, it will be called after step 1 as executes the goals bound to all phases up to install
.
Building a project like this with a single mvn install
is what Maven was designed to do; having to call mvn
five times to build one project is definitely not the Maven Way.
That being said, you may run out of phases if all your steps logically belong to, say, the package
phase. In that case, the steps are executed in the order in which their <execution>
elements are listed in the pom.xml
.
Upvotes: 0