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

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

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.


Try running the maven commands from the parent project/directory with the -pl <project name> switch.


I think maven is trying to tell you that the parent you defined is not released/stable. In your pom the parent version is "0.5.1-SNAPSHOT" which can not/should not work if you want to release a single library module as it would be pointing to something that is not uniquely defined. Is there a stable version you can point to instead? Otherwise maybe the -am switch works in combination with -pl?

Edit

I tried this just now with maven 3.2 and it does ask me for what version the parent should be set/resolved to. It is as I stated previously you need stable version numbers for the release to work

mvn release:prepare -pl library1
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building library1 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) @ library1 ---
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: **\release.properties, **\pom.xml.next, **\pom.xml.releaseBackup,     **\pom.xml.backup, **\pom.xml.branch, **\pom.xml.tag [INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\temp\mavenTest\library1
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Dependency 'testme:parent' is a snapshot (1.1-SNAPSHOT)
: Which release version should it be set to? 1.1: :

the trick is both:

  1. to repeat the -pl Param inside an additional -Darguments Param, to pass the -pl Param to the Child-Maven-Processes
  2. the mysterious mavenExecutor, to be able to create the Child-Maven-Processes using the given -pl Param

This should work:

mvn -pl library1 -DmavenExecutorId=forked-path -Darguments="-pl library1" 

Need Your Help

Exceptions & Interrupts

exception assembly terminology interrupt interrupted-exception

When I was searching for a distinction between Exceptions and Interrupts,

Converting a unix time to a human readable format

c++ unix time

I'm building my own unix time to human readable conversion, and I'm stuck.