maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r567988 - in /maven/release/trunk: maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ maven-release-manager/src/main/mdo/ maven-release-mana...
Date Tue, 21 Aug 2007 07:12:07 GMT
Author: brett
Date: Tue Aug 21 00:12:06 2007
New Revision: 567988

URL: http://svn.apache.org/viewvc?rev=567988&view=rev
Log:
[MRELEASE-124] add an "allowTimestampedSnapshots" parameter
Submitted by: Brian Topping, Tuomas Kiviaho

Added:
    maven/release/trunk/maven-release-manager/src/test/resources/projects/check-dependencies/external-timestamped-snapshot-dependencies/
    maven/release/trunk/maven-release-manager/src/test/resources/projects/check-dependencies/external-timestamped-snapshot-dependencies/pom.xml
  (with props)
Modified:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java
    maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java
    maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java?rev=567988&r1=567987&r2=567988&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java
Tue Aug 21 00:12:06 2007
@@ -73,7 +73,7 @@
         mergeInto.setUpdateBranchVersions( toBeMerged.isUpdateBranchVersions() );
         mergeInto.setUpdateWorkingCopyVersions( toBeMerged.isUpdateWorkingCopyVersions()
);
         mergeInto.setUpdateVersionsToSnapshot( toBeMerged.isUpdateVersionsToSnapshot() );
-
+        mergeInto.setAllowTimestampedSnapshots( toBeMerged.isAllowTimestampedSnapshots()
);
         mergeInto.setAutoVersionSubmodules( toBeMerged.isAutoVersionSubmodules() );
 
         // These must be overridden, as they are not stored

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java?rev=567988&r1=567987&r2=567988&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java
Tue Aug 21 00:12:06 2007
@@ -123,7 +123,7 @@
 
         if ( project.getParentArtifact() != null )
         {
-            if ( checkArtifact( project.getParentArtifact(), originalVersions, artifactMap
) )
+            if ( checkArtifact( project.getParentArtifact(), originalVersions, artifactMap,
releaseDescriptor ) )
             {
                 snapshotDependencies.add( project.getParentArtifact() );
             }
@@ -137,7 +137,7 @@
             {
                 Artifact artifact = (Artifact) i.next();
 
-                if ( checkArtifact( artifact, originalVersions, artifactMap ) )
+                if ( checkArtifact( artifact, originalVersions, artifactMap, releaseDescriptor
) )
                 {
                     snapshotDependencies.add( artifact );
                 }
@@ -152,7 +152,7 @@
         {
             Artifact artifact = (Artifact) i.next();
 
-            if ( checkArtifact( artifact, originalVersions, artifactMap ) )
+            if ( checkArtifact( artifact, originalVersions, artifactMap, releaseDescriptor
) )
             {
                 boolean addToFailures = true;
 
@@ -202,7 +202,7 @@
         {
             Artifact artifact = (Artifact) i.next();
 
-            if ( checkArtifact( artifact, originalVersions, artifactMap ) )
+            if ( checkArtifact( artifact, originalVersions, artifactMap, releaseDescriptor
) )
             {
                 //snapshotDependencies.add( artifact );
                 snapshotReportDependencies.add( artifact );
@@ -213,7 +213,7 @@
         {
             Artifact artifact = (Artifact) i.next();
 
-            if ( checkArtifact( artifact, originalVersions, artifactMap ) )
+            if ( checkArtifact( artifact, originalVersions, artifactMap, releaseDescriptor
) )
             {
                 snapshotExtensionsDependencies.add( artifact );
             }
@@ -245,7 +245,7 @@
         }
     }
 
-    private static boolean checkArtifact( Artifact artifact, Map originalVersions, Map artifactMapByVersionlessId
)
+    private static boolean checkArtifact( Artifact artifact, Map originalVersions, Map artifactMapByVersionlessId,
ReleaseDescriptor releaseDescriptor )
     {
         String versionlessId = ArtifactUtils.versionlessKey( artifact );
         Artifact checkArtifact = (Artifact) artifactMapByVersionlessId.get( versionlessId
);
@@ -255,17 +255,25 @@
             checkArtifact = artifact;
         }
         
-        return checkArtifact( checkArtifact, originalVersions );
+        return checkArtifact( checkArtifact, originalVersions, releaseDescriptor );
     }
     
-    private static boolean checkArtifact( Artifact artifact, Map originalVersions )
+    private static boolean checkArtifact( Artifact artifact, Map originalVersions, ReleaseDescriptor
releaseDescriptor )
     {
         String versionlessArtifactKey = ArtifactUtils.versionlessKey( artifact.getGroupId(),
artifact.getArtifactId() );
 
         // We are only looking at dependencies external to the project - ignore anything
found in the reactor as
         // it's version will be updated
-        return artifact.isSnapshot() &&
+        boolean result = artifact.isSnapshot() &&
             !artifact.getBaseVersion().equals( originalVersions.get( versionlessArtifactKey
) );
+
+        // If we have a snapshot but allowTimestampedSnapshots is true, accept the artifact
if the version
+        // indicates that it is a timestamped snapshot.
+        if ( result && releaseDescriptor.isAllowTimestampedSnapshots() ) {
+            result = artifact.getVersion().contains("SNAPSHOT");
+        }
+
+        return result;
     }
 
     public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, Settings settings,
List reactorProjects )

Modified: maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo?rev=567988&r1=567987&r2=567988&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo (original)
+++ maven/release/trunk/maven-release-manager/src/main/mdo/release-descriptor.mdo Tue Aug
21 00:12:06 2007
@@ -351,6 +351,16 @@
             Whether to update branch versions to SNAPSHOT.
           </description>
         </field>
+        <field>
+          <name>allowTimestampedSnapshots</name>
+          <version>1.0.0</version>
+          <type>boolean</type>
+          <defaultValue>false</defaultValue>
+          <description>
+            Should timestamped SNAPSHOT dependencies be allowed?  Default is to fail when
any SNAPSHOT
+              dependency is found.
+          </description>
+        </field>
 
         <!-- Announcement Information
 

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java?rev=567988&r1=567987&r2=567988&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.java
Tue Aug 21 00:12:06 2007
@@ -951,6 +951,37 @@
         assertTrue( true );
     }
 
+    public void testAllowTimestampedSnapshots()
+        throws Exception
+    {
+        ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
+        List reactorProjects = createDescriptorFromProjects( "external-timestamped-snapshot-dependencies"
);
+
+        releaseDescriptor.setInteractive( false );
+
+        // confirm POM fails without allowTimestampedSnapshots
+        try
+        {
+            phase.execute( releaseDescriptor, null, reactorProjects );
+
+            fail( "Should have failed execution" );
+        }
+        catch ( ReleaseFailureException e )
+        {
+            assertTrue( true );
+        }
+
+        // check whether flag allows
+        releaseDescriptor.setAllowTimestampedSnapshots(true);
+
+        phase.execute( releaseDescriptor, null, reactorProjects );
+
+        phase.simulate( releaseDescriptor, null, reactorProjects );
+
+        // successful execution is verification enough
+        assertTrue( true );
+    }
+    
     private List createDescriptorFromProjects( String path )
         throws Exception
     {

Added: maven/release/trunk/maven-release-manager/src/test/resources/projects/check-dependencies/external-timestamped-snapshot-dependencies/pom.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/resources/projects/check-dependencies/external-timestamped-snapshot-dependencies/pom.xml?rev=567988&view=auto
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/resources/projects/check-dependencies/external-timestamped-snapshot-dependencies/pom.xml
(added)
+++ maven/release/trunk/maven-release-manager/src/test/resources/projects/check-dependencies/external-timestamped-snapshot-dependencies/pom.xml
Tue Aug 21 00:12:06 2007
@@ -0,0 +1,30 @@
+<!--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>groupId</groupId>
+  <artifactId>artifactId</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>external</groupId>
+      <artifactId>artifactId</artifactId>
+      <version>1.0-20060424.060453-1</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/release/trunk/maven-release-manager/src/test/resources/projects/check-dependencies/external-timestamped-snapshot-dependencies/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java?rev=567988&r1=567987&r2=567988&view=diff
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
(original)
+++ maven/release/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
Tue Aug 21 00:12:06 2007
@@ -110,6 +110,13 @@
      */
     private boolean commitByProject;
 
+    /**
+     * Whether to timestamped SNAPSHOT dependencies.  Default is to fail when finding any
SNAPSHOT.
+     *
+     * @parameter expression="${ignoreSnapshots}" default-value="false"
+     */
+    private boolean allowTimestampedSnapshots;
+    
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -123,6 +130,7 @@
         config.setCommitByProject( commitByProject );
         config.setUpdateDependencies( updateDependencies );
         config.setAutoVersionSubmodules( autoVersionSubmodules );
+        config.setAllowTimestampedSnapshots( allowTimestampedSnapshots );
         try
         {
             releaseManager.prepare( config, settings, reactorProjects, resume, dryRun );



Mime
View raw message