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

62,962

Solution 1

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.

Solution 2

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

Solution 3

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" 
Share:
62,962
sangupta
Author by

sangupta

A Java/J2EE/Flex/AIR developer who's passionate about programming. Reading and asking questions is the best way to hone skills.

Updated on January 20, 2020

Comments

  • sangupta
    sangupta over 4 years

    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