Ori Marko
Ori Marko

Reputation: 58772

Eclipse run different maven goals on several projects

I have few maven projects while using Eclipse Neon,

I need to run different goals on different projects to be execute as a sequence/

I found an answer that I can't, or an answer for same goal

Example of usage: call clean install of project A and B, clean install -X on project C and then clean install tomcat7:run-war -X on project D

Upvotes: 0

Views: 2930

Answers (2)

jhamon
jhamon

Reputation: 3691

One way to do that is to run maven using command line.

Basic format is :

mvn [goal [goal2 [goal3] ...]]

clean and install are standard goals.

tomcat7:run-war is a plugin goal.

You surely have a <plugin> section in the pom.xml setting the property for this goal. You can find all other goals for tomcat7 plugin here: http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/plugin-info.html

You need to get in each of your projects folder and run the command with approriate goals:

cd <project_A_pom_directory>
mvn clean install
cd <project_B_pom_directory>
mvn clean install -X
cd <project_C_pom_directory>
mvn clean install tomcat7:run-war -X

Upvotes: 1

J Fabian Meier
J Fabian Meier

Reputation: 35805

If you install a command line Maven, you can call mvn clean install from your shell or cmd. Then you can write a sh or bat file that navigates into the right folders and calls the mvn command.

If you generally want to build all the projects, think about multi-module projects. If this is too much refactoring, you can also define a separate project (as reactor project) that includes your four projects as modules. Running mvn clean install on the whole project would then run the command on all the including modules. In the multi-module setting, it is unfortunately not possible to run diffferent Maven goals for the different modules (https://stackoverflow.com/a/4112696/927493). You either need to call Maven twice (with a different list of modules) or add the tomcat goal to your install phase in the relevant module.

Upvotes: 1

Related Questions