55

How do i deploy only the sub-modules of the project? i have a project as;

ProjectA
 -  Submodule B
 - Submodlue C
 - Submodule D 

The submodules are packaged as jar and is deployed to maven repo.how can only the sub -modules be deployed to the maven repository and not the main project?

Nazia
  • 551
  • 1
  • 4
  • 3

6 Answers6

78

Put this in module(s)(or module's pom.xml) that you don't want to deploy:

<properties>
  <maven.deploy.skip>true</maven.deploy.skip>
</properties>

Since this is inherited by submodules, you have to put this in submodules that you do want to deploy:

<properties>
  <maven.deploy.skip>false</maven.deploy.skip>
</properties>
Mark Lagendijk
  • 6,247
  • 2
  • 36
  • 24
vishwambhar
  • 888
  • 7
  • 3
  • 4
    The skip property will be `true` in all submodules... so nothing at all will be deployed.... – dokaspar Jun 13 '17 at 08:45
  • 1
    @dokaspar just set the skip property to `false` for all the submodules you want to deploy... – jansohn Aug 23 '17 at 14:13
  • Also if you have a situation where you need to deploy overlapping sets of module, use profiles. Example: module is [m1, m2, m3] user setting-foo deploy[m1, m2] and under 'setting-bar' deploy[m2, m3] ref: [maven-profile](https://maven.apache.org/guides/introduction/introduction-to-profiles.html) – old-monk Sep 07 '22 at 23:21
18

Another suggestion could be doing the following:

mvn deploy -pl SubModuleB
daemon_nio
  • 1,446
  • 1
  • 16
  • 19
10

This worked for me. Similar to other answer except added missing plugins element. Add to parent POM.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
    </plugins>
</build>
PaulT
  • 4,266
  • 2
  • 13
  • 15
  • 3
    You also need to re-enable the deploy for each sub-module that you want to deploy with a false – stenix Apr 19 '17 at 14:24
9

You can use the technique described in my blog.

In this case, you'd disable default-deploy (or what the name is) in the root pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <executions>
        <execution>
            <id>default-deploy</id>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>

And then enable it for submodules:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <executions>
        <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
        </execution>
    </executions>
</plugin>
David Dossot
  • 33,403
  • 4
  • 38
  • 72
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
9

This is working on my side Put the plugin declaration in the parent pom , skip=true, but set inherited=false. This prevents from repeating the on each child modules.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.8.2</version>
            <configuration>
                <skip>true</skip>
            </configuration>
            <inherited>false</inherited>
        </plugin>
skay
  • 1,681
  • 1
  • 14
  • 13
1

You can configure the maven-deploy-plugin in the POM of a module to exclude it from the deploy:

<build>
  <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-deploy-plugin</artifactId>
     <version>2.4</version>
     <configuration>
       <skip>true</skip>
     </configuration>
   </plugin>
   ...
</build>
Raghu
  • 41
  • 1
  • 7
  • 1
    Hi Raghu ...couldnt make it work ...tried putting the code into parent pm,but it gives the same result – Nazia Sep 28 '11 at 13:42