Wednesday, October 27, 2010

Passing properties to the Maven release plugin

The Maven release plugin does not propagate system properties to the maven release build. This can cause confusion when you try to set properties for a maven release. For example, if your pom.xml uses a custom property "some-property" that you intend to set for a release, you might be tempted to try this:

mvn release:prepare -Dsome-property=foo

Although this works for regular build, it will not work for a release build. This is because the release plugin forks a new instance for the release build, and properties passed to the parent are not propagated to the forked build.

To solve this problem, you need to propagate the properties yourself by configuring the argument property of the release plugin. For example:


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.overstock.example</groupId>
<artifactId>helloworld</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>helloworld</name>
<url>http://maven.apache.org</url>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<arguments>-Dsome-property=${some-property}</arguments>
</configuration>
</plugin>
</plugins>
</build>

</project>


If you need to propagate more than 1 property, the arguments property allows for multiple values separated by spaces.

11 comments:

  1. This really helped! Thanks alot mate

    ReplyDelete
  2. Hello, I just wanted to compliment and thank you for your excellent work. As I guess, this is one of the most unique and informative sites that I visited in a couple of days. As you have great and engaging content and very well laid out and it was easy to read and understand. I also do a similar kind of content marketing practice. Please have a look and share your views.

    seo india
    india seo service company
    Hire Data Scientists
    front end web developer

    ReplyDelete
  3. Hello there! This is my first comment here, so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles.

    virtual assistant
    freelance web developer
    freelance web developer

    ReplyDelete
  4. I wish for the great of success in all of our destiny endeavors 검증업체

    ReplyDelete
  5. I intended to put you one very small word to help give thanks as
    before with the extraordinary thoughts you have shared in this case.대구오피


    ReplyDelete
  6. Excellent post however , I was wondering if you could write a litte more on this subject?
    I’d be very grateful if you could elaborate a little bit further.
    Thank you!

    my web page; 대구오피
    (jk)

    ReplyDelete
  7. When some one searches for his vital thing, thus he/she desires to be available
    that in detail, so that thing is maintained over here.
    click me here 바카라
    LG

    ReplyDelete
  8. I got this web site from my friend who informed me regarding this website and at the moment this time I am visiting
    this web page and reading very informative content here.
    메이저사이트
    온라인경마

    ReplyDelete
  9. I like the helpful information you supply to your articles. I'll bookmark your weblog and test again here regularly. I am fairly certain I'll be informed many new stuff proper here!
    Best of luck for the following!
    바카라사이트
    토토사이트

    ReplyDelete
  10. Wow, amazing blog layout! How lengthy have you been running
    a blog for? you make running a blog glance easy. The full glance of your website is great, as neatly as the content material!
    majortotositepro1
    racesitepro1
    oncasinositenet1
    totopickpro1

    ReplyDelete
  11. Herbal Treatment: Cure Herpes Virus Permanently. A Lasting Solution..Great service... robinsonbucler @ Gmail.....com,,,,,,,,,,,,,,,,,,,,,,,,,,,

    ReplyDelete