You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2005/10/11 22:01:50 UTC

svn commit: r312948 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java maven-repository-metadata/src/main/mdo/metadata.mdo

Author: jdcasey
Date: Tue Oct 11 13:01:43 2005
New Revision: 312948

URL: http://svn.apache.org/viewcvs?rev=312948&view=rev
Log:
Fixing standalone maven-core build...fixing metadata merge where lastUpdated == "null" (null-string)...and finally, disabling plugin resolution from referencing the current project, since this will really screw up builds of plugins that are referenced in the plugin lifecycle mapping...like maven-surefire-plugin.

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
    maven/components/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?rev=312948&r1=312947&r2=312948&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java Tue Oct 11 13:01:43 2005
@@ -93,23 +93,33 @@
         // first pass...if the plugin is specified in the pom, try to retrieve the version from there.
         String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
 
+        // NOTE: [jc; 11-Oct-2005] We CANNOT have this type of code in here. It will prevent plugins from building themselves,
+        // if they are part of the lifecycle mapping. For example, try the following:
+        //
+        // 1. Uncomment the remainder of the following code block and rebuild the core jar; put it in the m2 distro
+        // 2. rm -Rf <local-repo>/org/apache/maven/plugins/maven-surefire-plugin
+        // 3. go to <maven>/maven-plugins/maven-surefire-plugin, and try to build it.
+        //
+        // In the above example, the surefire plugin fails to build because the version used for testing is
+        // resolved to the version currently being built...which obviously doesn't exist yet.
+        
         // if there was no explicit version, try for one in the reactor
         if ( version == null )
         {
             // check self
-            if ( project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) )
-            {
-                version = project.getVersion();
-            }
-            else if ( project.getProjectReferences() != null )
-            {
+//            if ( project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) )
+//            {
+//                version = project.getVersion();
+//            }
+//            else if ( project.getProjectReferences() != null )
+//            {
                 String refId = ArtifactUtils.versionlessKey( groupId, artifactId );
                 MavenProject ref = (MavenProject) project.getProjectReferences().get( refId );
                 if ( ref != null )
                 {
                     version = ref.getVersion();
                 }
-            }
+//            }
         }
 
         // we're NEVER going to persist POM-derived plugin versions.
@@ -640,70 +650,61 @@
     {
         Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
 
-        project.replaceWithActiveArtifact( artifact );
-
         String version = null;
 
-        if ( artifact.isResolved() )
-        {
-            version = artifact.getVersion();
-        }
-        else
+        try
         {
-            try
+            ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository,
+                                                                               project.getPluginArtifactRepositories() );
+
+            // switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
+            // artifact.
+            artifact = resolutionGroup.getPomArtifact();
+
+            // make sure this artifact was actually resolved to a file in the repo...
+            if ( artifact.getFile() != null )
             {
-                ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository,
-                                                                                   project.getPluginArtifactRepositories() );
+                MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project
+                    .getPluginArtifactRepositories(), localRepository, false );
 
-                // switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
-                // artifact.
-                artifact = resolutionGroup.getPomArtifact();
+                boolean pluginValid = true;
 
-                // make sure this artifact was actually resolved to a file in the repo...
-                if ( artifact.getFile() != null )
+                // if we don't have the required Maven version, then ignore an update
+                if ( pluginProject.getPrerequisites() != null &&
+                    pluginProject.getPrerequisites().getMaven() != null )
                 {
-                    MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project
-                        .getPluginArtifactRepositories(), localRepository, false );
+                    DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
+                        pluginProject.getPrerequisites().getMaven() );
 
-                    boolean pluginValid = true;
-
-                    // if we don't have the required Maven version, then ignore an update
-                    if ( pluginProject.getPrerequisites() != null &&
-                        pluginProject.getPrerequisites().getMaven() != null )
+                    if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
                     {
-                        DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
-                            pluginProject.getPrerequisites().getMaven() );
-
-                        if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
-                        {
-                            getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
-                                " as it requires Maven version " + requiredVersion );
-                            pluginValid = false;
-                        }
+                        getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
+                            " as it requires Maven version " + requiredVersion );
+                        pluginValid = false;
                     }
+                }
 
-                    String artifactVersion = artifact.getVersion();
+                String artifactVersion = artifact.getVersion();
 
-                    if ( pluginValid && !metaVersionId.equals( artifactVersion ) )
-                    {
-                        version = artifactVersion;
-                    }
+                if ( pluginValid && !metaVersionId.equals( artifactVersion ) )
+                {
+                    version = artifactVersion;
                 }
             }
-            catch ( ArtifactMetadataRetrievalException e )
-            {
-                getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
-            }
-            catch ( ProjectBuildingException e )
-            {
-                throw new PluginVersionResolutionException( groupId, artifactId,
-                                                            "Unable to build resolve plugin project information", e );
-            }
-            catch ( IOException e )
-            {
-                throw new PluginVersionResolutionException( groupId, artifactId,
-                                                            "Unable to determine Maven version for comparison", e );
-            }
+        }
+        catch ( ArtifactMetadataRetrievalException e )
+        {
+            getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
+        }
+        catch ( ProjectBuildingException e )
+        {
+            throw new PluginVersionResolutionException( groupId, artifactId,
+                                                        "Unable to build resolve plugin project information", e );
+        }
+        catch ( IOException e )
+        {
+            throw new PluginVersionResolutionException( groupId, artifactId,
+                                                        "Unable to determine Maven version for comparison", e );
         }
 
         return version;

Modified: maven/components/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo?rev=312948&r1=312947&r2=312948&view=diff
==============================================================================
--- maven/components/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo (original)
+++ maven/components/trunk/maven-repository-metadata/src/main/mdo/metadata.mdo Tue Oct 11 13:01:43 2005
@@ -108,6 +108,16 @@
                     v.getVersions().add( version );
                 }
             }
+          
+            if ( "null".equals( versioning.getLastUpdated() ) )
+            {
+                versioning.setLastUpdated( null );
+            }
+
+            if ( "null".equals( v.getLastUpdated() ) )
+            {
+                v.setLastUpdated( null );
+            }
 
             if ( versioning.getLastUpdated() == null || versioning.getLastUpdated().length() == 0 )
             {