开发者

How to Deploy only the sub-modules using maven deploy?

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 开发者_如何学JAVAthe maven repository and not the main project?


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>


Another suggestion could be doing the following:

mvn deploy -pl SubModuleB


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>


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>


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>


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜