Trigger a maven install command from another maven install command

maven-2

Solution

The Maven way to "trigger" another build is to define a multi-module build. A parent pom project can specify modules, that will all be built using the standard lifecycle. So running `mvn install` on the parent would mean that each module is built in turn.

The parent is defined with `pom` packagin, and would have a modules declaration like this:

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

Alternatively it is possible to attach additional artifacts to a build so they are deployed alongside the primary artifacts (assuming they've already been packaged, you can use the build-helper-maven-plugin to attach an arbitrary file to your pom, so it will be deployed with the specified classifier. The following configuration will attach 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>

Problem

Is there a way to trigger a maven install command from another maven install command? In other words, I would like to be able to execute a maven install command on a maven project (in eclipse) and I want that this will automatically cause an install command on another maven project. Is that possible?

Original source