Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: Build only one module out of multi-module project

Tags:

java

maven

build

I have a multi-module Maven project wherein I just want to release an update module rather than the entire project. This is due to some specific requirements, wherein a release of entire project is uncalled for - only a subset of the library needs the fixes and thus the release.

However, when I run a mvn release:prepare I get the following error Non-resolvable parent POM - I have setup the parent POM relationship in the module project with relativePath tag but that does not seem to work.

Is it possible to release only a module rather than releasing the entire project.

Thanks in advance.

EDIT

Parent pom

<groupId>com.domain</groupId> <artifactId>project-parent</artifactId> <version>0.5.1-SNAPSHOT</version>  <packaging>pom</packaging>  <modules>     <module>library1</module>     <module>library2</module>     <module>library3</module> </modules> 

The module POMs are as under:

<parent>     <groupId>com.domain></groupId>     <artifactId>project-parent</artifactId>     <version>0.5.1-SNAPSHOT</version> </parent>  <artifactId>library1</artifactId> 

Now I just want to release the new version of library1 and not others

like image 930
sangupta Avatar asked Feb 06 '14 15:02

sangupta


People also ask

Does Maven support multi project build?

Maven's Multi-Module Project The submodules are regular Maven projects, and they can be built separately or through the aggregator POM. By building the project through the aggregator POM, each project that has a packaging type different from pom will result in a built archive file.

Can two Maven modules depend on each other?

Because modules within a multi-module build can depend on each other, it is important that the reactor sorts all the projects in a way that guarantees any project is built before it is required. The following relationships are honoured when sorting projects: a project dependency on another module in the build.

How do I skip a module in Maven build?

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.


1 Answers

mvn -pl .,library1 clean install 

The "." will build your parent pom.xml and "library1" is the module name you gave it.

If you don't want to build the parent pom.xml, you can also do:

mvn -pl library1 clean install 

or in your case, maybe:

mvn -pl library1 deploy 

I used "deploy" because "release" is not a Maven build lifecycle phase.

like image 160
Gene Avatar answered Sep 25 '22 03:09

Gene