I have a multi-module maven project, and would like to deploy only 2 sub modules:
pom.xml // parent pom
module1
--pom.xml
module2
--pom.xml
module3
--pom.xml
only module1.jar
and module2.jar
should be deployed.
I have a multi-module maven project, and would like to deploy only 2 sub modules:
pom.xml // parent pom
module1
--pom.xml
module2
--pom.xml
module3
--pom.xml
only module1.jar
and module2.jar
should be deployed.
I have found the solution in the following question:
How to Deploy only the sub-modules using maven deploy?
The following property should be added to the pom.xml
set to true
for the modules that should not be deployed:
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
From my personal experience, we had a multi maven project. Where many modules was features that some clients had it and some other clients dint had them. For example when we build for 'clientA' we wanted Jenkins to package 'module1', 'module2' and 'module3' but when we build for 'clientB' we wanted only to package 'module1' and 'module2' to just give him the base functionality.
So, its not absolutely wrong to deploy/release part of a multi module project. In the above example there are a case where you need to build some of the modules and a case where you want to build all the modules. In those cases you can do that with profiles.
Example: in parent pom.xml
<profiles>
<profile>
<id>base-functionality</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>/module1</module>
<module>/module2</module>
</modules>
</profile>
<profile>
<id>new-feature</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<modules>
<module>/module3</module>
</modules>
</profile>
</profiles>
and then on Jenkins job for "clientA":
clean package -Pbase-functionality,new-feature
where on Jenkins job for 'clientB':
clean package -Pbase-functionality
Note: as khmarbaise stated on comment below this approach has same pitfalls and should be avoided if possible.