Friday, June 26, 2009

Maven: Excluding a Module Artifact from the Deploy Phase

I have a multi-module Maven project where one's module purpose is to create an assembly which is of a good size. I would like the other module's artifacts be deployed to our remote repository when mvn deploy is run, but would like to avoid having the assembled artifact deployed due to its size.

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>
If done, correctly you should see the following after running mvn deploy in your build output:
[INFO] [deploy:deploy]
[INFO] skipping artifact deployement
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

3 comments:

  1. Nice article! It helped me a lot. Wrote an article where a link to this article:

    http://myossdevblog.blogspot.com/2010/02/some-words-about-microlog-and-some.html

    ReplyDelete
  2. Hi,
    Can we avoid the deployment of the parent POM with the above code?

    the parent POM in my project doesnt do anything , so it would be senseless to put it in the repo.
    is there a way to avoid deployment of parent POM?
    Please help.
    Thanks,
    NAzia

    ReplyDelete
  3. Hey Nazia, if you run "mvn deploy" from the child module, the parent POM should not be deployed. If you are running from the parent's directory, I think you can put the same configuration in the parent POM turning inheritance off:

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.4</version>
    <configuration>
    <skip>true</skip>
    </configuration>
    <inherited>false</inherited>
    <plugin>

    ReplyDelete