You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/09/16 09:13:22 UTC

svn commit: r289409 - in /maven/components/trunk/maven-mboot2/src/main/java/model: Dependency.java Exclusion.java ModelReader.java

Author: brett
Date: Fri Sep 16 00:13:15 2005
New Revision: 289409

URL: http://svn.apache.org/viewcvs?rev=289409&view=rev
Log:
let bootstrap handle exclusions

Added:
    maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java   (with props)
Modified:
    maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java
    maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java

Modified: maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java?rev=289409&r1=289408&r2=289409&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java (original)
+++ maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java Fri Sep 16 00:13:15 2005
@@ -1,5 +1,8 @@
 package model;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
  *
@@ -47,6 +50,8 @@
 
     public static final String SCOPE_RUNTIME = "runtime";
 
+    private Set exclusions = new HashSet();
+
     public Dependency()
     {
     }
@@ -273,5 +278,15 @@
             resolvedVersion = getVersion();
         }
         return resolvedVersion;
+    }
+
+    public void addExclusion( Exclusion currentExclusion )
+    {
+        exclusions.add( currentExclusion.getConflictId() );
+    }
+
+    public Set getExclusions()
+    {
+        return exclusions;
     }
 }

Added: maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java?rev=289409&view=auto
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java (added)
+++ maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java Fri Sep 16 00:13:15 2005
@@ -0,0 +1,55 @@
+package model;
+
+/*
+ * Copyright 2001-2005 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.
+ */
+
+/**
+ * Excluded dependency.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class Exclusion
+{
+    private String groupId;
+
+    private String artifactId;
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public String getConflictId()
+    {
+        return groupId + ":" + artifactId + ":jar";
+    }
+}

Propchange: maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java?rev=289409&r1=289408&r2=289409&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java (original)
+++ maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java Fri Sep 16 00:13:15 2005
@@ -100,6 +100,10 @@
 
     private boolean insideSnapshots;
 
+    private boolean insideExclusion;
+
+    private Exclusion currentExclusion;
+
     public ModelReader( ArtifactDownloader downloader, boolean resolveTransitiveDependencies )
     {
         this.downloader = downloader;
@@ -222,9 +226,9 @@
             // actually, these should be transtive (see MNG-77) - but some projects have circular deps that way (marmalade, and currently m2)
             ModelReader p = retrievePom( parentGroupId, parentArtifactId, parentVersion, "pom", false );
 
-            addDependencies( p.getDependencies(), parentDependencies, null );
+            addDependencies( p.getDependencies(), parentDependencies, null, Collections.EMPTY_SET );
 
-            addDependencies( p.getManagedDependencies(), managedDependencies, null );
+            addDependencies( p.getManagedDependencies(), managedDependencies, null, Collections.EMPTY_SET );
 
             resources.addAll( p.getResources() );
 
@@ -243,6 +247,11 @@
                 dependencies.put( currentDependency.getConflictId(), currentDependency );
             }
         }
+        else if ( rawName.equals( "exclusion" ) )
+        {
+            currentDependency.addExclusion( currentExclusion );
+            insideExclusion = false;
+        }
         else if ( rawName.equals( "dependencyManagement" ) )
         {
             insideDependencyManagement = false;
@@ -282,7 +291,18 @@
         }
         else if ( insideDependency )
         {
-            if ( rawName.equals( "id" ) )
+            if ( insideExclusion )
+            {
+                if ( rawName.equals( "groupId" ) )
+                {
+                    currentExclusion.setGroupId( getBodyText() );
+                }
+                else if ( rawName.equals( "artifactId" ) )
+                {
+                    currentExclusion.setArtifactId( getBodyText() );
+                }
+            }
+            else if ( rawName.equals( "id" ) )
             {
                 currentDependency.setId( getBodyText() );
             }
@@ -310,6 +330,12 @@
             {
                 currentDependency.setScope( getBodyText() );
             }
+            else if ( rawName.equals( "exclusion" ) )
+            {
+                insideExclusion = true;
+
+                currentExclusion = new Exclusion();
+            }
         }
         else if ( insideResource )
         {
@@ -401,8 +427,9 @@
                 Dependency managedDependency = (Dependency) managedDependencies.get( dependency.getConflictId() );
                 if ( managedDependency == null )
                 {
-                    throw new NullPointerException( "[" + groupId + ":" + artifactId +":" + packaging + ":" + version + "] " +
-                            "Dependency " + dependency.getConflictId() + " is missing a version, and nothing is found in dependencyManagement. ");
+                    throw new NullPointerException( "[" + groupId + ":" + artifactId + ":" + packaging + ":" + version +
+                        "] " + "Dependency " + dependency.getConflictId() +
+                        " is missing a version, and nothing is found in dependencyManagement. " );
                 }
                 dependency.setVersion( managedDependency.getVersion() );
             }
@@ -413,12 +440,13 @@
                                              dependency.getVersion(), dependency.getType(),
                                              resolveTransitiveDependencies );
 
-                addDependencies( p.getDependencies(), transitiveDependencies, dependency.getScope() );
+                addDependencies( p.getDependencies(), transitiveDependencies, dependency.getScope(),
+                                 dependency.getExclusions() );
             }
         }
     }
 
-    private void addDependencies( Collection dependencies, Map target, String inheritedScope )
+    private void addDependencies( Collection dependencies, Map target, String inheritedScope, Set excluded )
     {
         for ( Iterator i = dependencies.iterator(); i.hasNext(); )
         {
@@ -430,7 +458,7 @@
                 d.setScope( Dependency.SCOPE_TEST );
             }
 
-            if ( !hasDependency( d, target ) )
+            if ( !hasDependency( d, target ) && !excluded.contains( d.getConflictId() ) )
             {
                 target.put( d.getConflictId(), d );
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org