Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip the release or specific modules in the maven repo

Heyho,

I have a maven project with this scructure:

parent:

  • List item
  • API module
  • module2
  • ...
  • module5
  • test
  • distribution/assembly

So first i run the parent module, then I run the module which builds the api, then the modules which depend on the api, then a test module which contains tools to test and at the end I run a assembly/distribution where I package some modules in a archive. Because of some problems I can not really change the way and it works so far perfect.

With the jenkins I release it to the maven repo, but I want only to release for example the API, and a few modules, not the test module and the distribution module. Is there a way to skip them? Dont't want to release stuff I dont really need :/

like image 661
maxammann Avatar asked Jan 12 '13 17:01

maxammann


People also ask

How do I skip a particular module in Maven?

Maven version 3.2. 1 added this feature, you can use the -pl switch (shortcut for --projects list) with ! or - (source) to exclude certain submodules. Be careful in bash the character ! is a special character, so you either have to single quote it (like I did) or escape it with the backslash character.

How do I skip a project in Maven build?

To skip running the tests for a particular project, set the skipTests property to true. You can also skip the tests via the command line by executing the following command: mvn install -DskipTests.

What is multi-module project in Maven?

A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom. The submodules are regular Maven projects, and they can be built separately or through the aggregator POM.


1 Answers

To understand you correctly, you still want to run the test modules, but your don't want to deploy/release them. The maven-deploy-plugin to the rescue! To artifact will still be built, but not deployed.

  <plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-deploy-plugin</artifactId>     <version>2.7</version>     <configuration>         <skip>true</skip>     </configuration>   </plugin> 

However, the jenkins release plugin will still release all artifacts. Instead of using the jenkins release plugin, think about releasing with the maven-release-plugin, which is easy to do:

mvn release:prepare mvn release:perform 

Since the default goals are deploy and site, all should be ok.

Just make sure you have a scm tag in your root pom:

<scm>     <connection>scm:svn|git:https://...</connection>     <developerConnection>scm:svn|git:https://...</developerConnection> </scm> 

and that your versioning tool command (git, svn, ...) is available on the PATH.

like image 197
asgoth Avatar answered Sep 19 '22 13:09

asgoth