You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2006/01/16 18:02:24 UTC

svn commit: r369527 - /maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java

Author: jvanzyl
Date: Mon Jan 16 09:02:23 2006
New Revision: 369527

URL: http://svn.apache.org/viewcvs?rev=369527&view=rev
Log:
[MRELEASE-69] User should be warned up-front if there external snapshot dependencies in the build

Modified:
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java?rev=369527&r1=369526&r2=369527&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java Mon Jan 16 09:02:23 2006
@@ -209,6 +209,22 @@
         }
     }
 
+    private Set createReactorProjectSet( List reactorProjects )
+    {
+        Set reactorProjectSet = new HashSet();
+
+        for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+        {
+            MavenProject project = (MavenProject) it.next();
+
+            String versionlessArtifactKey = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+
+            reactorProjectSet.add( versionlessArtifactKey );
+        }
+
+        return reactorProjectSet;
+    }
+
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -220,6 +236,21 @@
         {
             checkForLocalModifications();
 
+            // ----------------------------------------------------------------------
+            // Walk through all the projects in the reactor so that we can check
+            // up-front that we don't have any snapshot dependencies hiding in one
+            // of the POMs.
+            // ----------------------------------------------------------------------
+
+            getLog().info( "Checking dependencies and plugins for snapshots ..." );
+
+            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+            {
+                MavenProject project = (MavenProject) it.next();
+
+                checkDependenciesForSnapshots( project, createReactorProjectSet( reactorProjects ) );
+            }
+
             if ( !getReleaseProgress().verifyCheckpoint( ReleaseProgressTracker.CP_POM_TRANSFORMED_FOR_RELEASE ) )
             {
                 Map releasedProjects = new HashMap();
@@ -228,8 +259,6 @@
                 {
                     MavenProject project = (MavenProject) it.next();
 
-                    checkForPresenceOfSnapshots( project );
-
                     String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
 
                     if ( !ArtifactUtils.isSnapshot( project.getVersion() ) )
@@ -611,30 +640,31 @@
 
             currentProject = parentProject;
         }
+    }
 
-        getLog().info( "Checking dependencies for snapshots ..." );
-
+    private void checkDependenciesForSnapshots( MavenProject project, Set reactorProjectSet )
+        throws MojoExecutionException
+    {
         Set snapshotDependencies = new HashSet();
 
         for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
         {
             Artifact artifact = (Artifact) i.next();
 
-            String artifactVersion = getVersionResolver().getResolvedVersion( artifact.getGroupId(),
-                                                                              artifact.getArtifactId() );
+            String versionlessArtifactKey = ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
 
-            if ( artifactVersion == null )
-            {
-                artifactVersion = artifact.getVersion();
-            }
+            // ----------------------------------------------------------------------
+            // We only care about dependencies that we are not processing as part
+            // of the release. Projects in the reactor will be dealt with so we
+            // don't need to worry about them here. We are strictly looking at
+            // dependencies that are external to this project.
+            // ----------------------------------------------------------------------
 
-            if ( ArtifactUtils.isSnapshot( artifactVersion ) )
+            if ( !reactorProjectSet.contains( versionlessArtifactKey ) && ArtifactUtils.isSnapshot( artifact.getVersion() ) )
             {
                 snapshotDependencies.add( artifact );
             }
         }
-
-        getLog().info( "Checking plugins for snapshots ..." );
 
         for ( Iterator i = project.getPluginArtifacts().iterator(); i.hasNext(); )
         {