Run the maven install command from another maven install command

Is there a way to run the maven install command from another maven install command?

In other words, I would like to be able to execute the maven install command in the maven project (in eclipse), and I want this to automatically invoke the install command in another maven project. Is it possible?

+6
maven-2
source share
2 answers

Maven's way to β€œstart” another assembly is to define a multi-module assembly . A parent pom project can specify modules to be built using the standard life cycle. Therefore, running mvn install on the parent will mean that each module will be built in turn.

The parent is defined using pom packagin and has a module declaration as follows:

 <modules> <module>module-a</module> <module>module-b</module> </modules> 

Alternatively, you can add additional artifacts to the assembly so that they are deployed next to the primary artifacts (if they have already been packaged, you can use build-helper-maven-plugin in attach any file for your pom, so it will be deployed with the specified classifier my-artifact-1.0-extra.jar following configuration attaches the specified file as my-artifact-1.0-extra.jar

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.3</version> <executions> <execution> <id>attach-artifacts</id> <phase>package</phase> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <artifact> <file>/path/to/extra/file.jar</file> <type>jar</type><!--or specify your required extension--> <classifier>extra</classifier> </artifact> </artifacts> </configuration> </execution> </executions> </plugin> 
+4
source share

As indicated, the maven way to run the target (say mvn install ) in a set of modules is to organize them as a multi-module project and run the target on the parent pom. Behind the scenes, Maven will use the "Maven Reactor" for this work. The reactor will calculate the assembly order by performing topological sorting of nodes of the directed graph constructed by the relationship of dependencies between the modules. This graph is plotted by viewing the <modules> and <dependencies> tags in the sweeps.

But running maven from the parent is not the only option, and maven offers more options for playing with the reactor (for example, creating a project and its dependencies or those that depend on it):

Check it out, it can help you achieve your goal.

+4
source share

All Articles