Maven reactor: Is it possible to build only the dependencies of a specific module, but not the module itself?

56 Views Asked by At

I would like to install all the dependencies of a given module (without the module itself), followed by a deploy of just the module.

mvn --file aggregator.xml clean install --also-make --projects :my-module-id
mvn --file aggregator.xml clean deploy --projects :my-module-id

Note 1: I cannot call just the deploy:deploy-goal on the module, because sometimes other goals are bound to the deploy-phase.

Note 2: I also need to avoid packaging :my-module-id twice, because it takes a long time.

Maven command line options help

Example aggregator.xml (reactor pom):

<project>
  <name>aggregator</name>
  
  <modules>
    <module>common-module-id</module>
    <module>my-module-id</module>
  </module>
</project>
1

There are 1 best solutions below

7
J Fabian Meier On

In case you never want to actually deploy those other modules (just install them to use them in the build), it would make more sense to set

<maven.deploy.skip>true</maven.deploy.skip>

in the modules that should not be deployed. Then you can safely call

mvn deploy --also-make --projects :my-module-id

without deploying stuff you do not need later.