2 Replies Latest reply on Mar 29, 2008 10:04 AM by adrian.brock

    Maven Version ranges - generateReleasePoms

      In order to capture what was actually used to build the release
      you need to generate a release pom. This is a release-pom.xml that gets checked in
      when you tag the release in release:perform.

       <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-release-plugin</artifactId>
       <version>2.0-beta-7</version>
       <configuration>
       <!-- The tagBase property is needed during the release process so that the maven release plugin
       - will create the tag in the appropriate svn location. If the svn location is the default
       - of "../tags" then we don't need to specify the tagBase. -->
      
       <tagBase>svn://localhost/project2/tags/</tagBase>
      
      <!-- HERE -->
      
       <generateReleasePoms>true</generateReleasePoms>
      
       <!-- We don't want to use the default release profile because it creates javadoc jars for the repo.
      
       - Since we include source jars in the repo, we don't need the javadoc jars. -->
       <useReleaseProfile>false</useReleaseProfile>
      
       <!-- The release plugin activates a custom profile called "release". -->
       <arguments>-Prelease</arguments>
       </configuration>
       <inherited>true</inherited>
       </plugin>
       </plugins>
      


      I think we should do this anyway even if we don't use version ranges.
      This captures all the information used to build the release including the
      user's ~/.m2/settings.xml relevant to the build

      e.g. you can see that during my testing I have been using some
      local repositories to get artifacts.

      <?xml version="1.0" encoding="UTF-8"?><project>
       <modelVersion>4.0.0</modelVersion>
       <groupId>test</groupId>
       <artifactId>project2</artifactId>
       <name>Project2</name>
       <version>1.0.0-Beta-5</version>
       <description>Project2</description>
       <url>http://www.jboss.org/project2</url>
       <issueManagement>
       <system>jira</system>
       <url>http://jira.jboss.com/</url>
       </issueManagement>
       <licenses>
       <license>
       <name>lgpl</name>
       <url>http://repository.jboss.com/licenses/lgpl.txt</url>
       </license>
       </licenses>
       <scm>
       <connection>svn://localhost/project2/tags/project2-1.0.0-Beta-5</connection>
       <developerConnection>svn://localhost/project2/tags/project2-1.0.0-Beta-5</developerConnection>
       </scm>
       <organization>
       <name>JBoss, a division of Red Hat, Inc.</name>
       <url>http://www.jboss.org</url>
       </organization>
       <build>
       <sourceDirectory>src/main</sourceDirectory>
       <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
       <testSourceDirectory>src/tests</testSourceDirectory>
       <outputDirectory>target/classes</outputDirectory>
       <testOutputDirectory>target/test-classes</testOutputDirectory>
       <resources>
       <resource>
       <directory>src/main/resources</directory>
       </resource>
       </resources>
       <testResources>
       <testResource>
       <directory>src/test/resources</directory>
       </testResource>
       </testResources>
       <directory>target</directory>
       <finalName>project2</finalName>
       <plugins>
       <plugin>
       <artifactId>maven-surefire-plugin</artifactId>
       <version>2.4.1</version>
       <configuration>
       <redirectTestOutputToFile>true</redirectTestOutputToFile>
       <includes>
       <include>**/*TestCase.java</include>
       </includes>
       <useSystemClassLoader>true</useSystemClassLoader>
       </configuration>
       </plugin>
       <plugin>
       <artifactId>maven-release-plugin</artifactId>
       <version>2.0-beta-7</version>
       <inherited>true</inherited>
       <configuration>
       <tagBase>svn://localhost/project2/tags/</tagBase>
       <generateReleasePoms>true</generateReleasePoms>
       <useReleaseProfile>false</useReleaseProfile>
       <arguments>-Prelease</arguments>
       </configuration>
       </plugin>
       </plugins>
       </build>
       <repositories>
       <repository>
       <releases>
       <enabled>false</enabled>
       </releases>
       <snapshots />
       <id>snapshots.jboss.org</id>
       <url>file:///home/ejort/temp/snapshots</url>
       </repository>
       <repository>
       <releases />
       <snapshots>
       <enabled>false</enabled>
       </snapshots>
       <id>repository.jboss.org</id>
       <url>http://repository.jboss.org/maven2</url>
       </repository>
       <repository>
       <releases />
       <snapshots>
       <enabled>false</enabled>
       </snapshots>
       <id>repository</id>
       <url>file:///home/ejort/temp/maven-repository</url>
       </repository>
       <repository>
       <snapshots>
       <enabled>false</enabled>
       </snapshots>
       <id>central</id>
       <name>Maven Repository Switchboard</name>
       <url>http://repo1.maven.org/maven2</url>
       </repository>
       </repositories>
       <pluginRepositories>
       <pluginRepository>
       <releases />
       <snapshots>
       <enabled>false</enabled>
       </snapshots>
       <id>repository.jboss.org</id>
       <url>http://repository.jboss.org/maven2</url>
       </pluginRepository>
       <pluginRepository>
       <releases>
       <updatePolicy>never</updatePolicy>
       </releases>
       <snapshots>
       <enabled>false</enabled>
       </snapshots>
       <id>central</id>
       <name>Maven Plugin Repository</name>
       <url>http://repo1.maven.org/maven2</url>
       </pluginRepository>
       </pluginRepositories>
       <dependencies>
       <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.4</version>
       <scope>test</scope>
       </dependency>
       <dependency>
       <groupId>test</groupId>
       <artifactId>project1</artifactId>
       <version>1.0.0-Beta-1</version>
       <scope>compile</scope>
       </dependency>
       </dependencies>
       <reporting>
       <outputDirectory>target/site</outputDirectory>
       <plugins>
       <plugin>
       <artifactId>maven-javadoc-plugin</artifactId>
       <version>2.2</version>
       <configuration>
       <links>
       <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
       </links>
       </configuration>
       </plugin>
       <plugin>
       <artifactId>maven-project-info-reports-plugin</artifactId>
       <version>2.0.1</version>
       </plugin>
       <plugin>
       <artifactId>maven-surefire-report-plugin</artifactId>
       <version>2.3</version>
       <reportSets>
       <reportSet>
       <reports>
       <report>report-only</report>
       </reports>
       </reportSet>
       </reportSets>
       </plugin>
       <plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>taglist-maven-plugin</artifactId>
       <version>2.0</version>
       </plugin>
       </plugins>
       </reporting>
       <distributionManagement>
       <repository>
       <id>repository.jboss.org</id>
       <url>file:///home/ejort/temp/maven-repository</url>
       </repository>
       <snapshotRepository>
       <id>snapshots.jboss.org</id>
       <name>JBoss Snapshot Repository</name>
       <url>file:///home/ejort/temp/snapshots</url>
       </snapshotRepository>
       </distributionManagement>
       <properties>
       <maven.repository.root>/home/ejort/temp/maven-repository</maven.repository.root>
       <jboss.repository.root>/home/ejort/temp/repository.jboss.org</jboss.repository.root>
       </properties>
      </project>
      


        • 1. Re: Maven Version ranges - generateReleasePoms

           

          "adrian@jboss.org" wrote:

          e.g. you can see that during my testing I have been using some
          local repositories to get artifacts.


          It would be even better if it told you where it got the artifacts from
          i.e. some xml element that said junit.jar came from repository.jboss.org
          and also listed more of the plugins actually used with their versions and configurations.

          • 2. Re: Maven Version ranges - generateReleasePoms

            The other thing I don't understand is why it is resolving the versions to
            a suggestion rather than a hard constraint.

            e.g. My constraint

             <dependency>
             <groupId>test</groupId>
             <artifactId>project1</artifactId>
             <version>[1.0.0-Beta-1,)</version>
             <scope>compile</scope>
             </dependency>
            


            becomes in the release-pom.xml

             <dependency>
             <groupId>test</groupId>
             <artifactId>project1</artifactId>
             <version>1.0.0-Beta-1</version>
             <scope>compile</scope>
             </dependency>
            


            why isn't this?

             <dependency>
             <groupId>test</groupId>
             <artifactId>project1</artifactId>
             <version>[1.0.0-Beta-1]</version>
             <scope>compile</scope>
             </dependency>
            


            which is what would be required to properly reproduce the build.