maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifedore...@apache.org
Subject maven git commit: MNG-5783 fixed slf4j is missing from ${plugin.artifacts}
Date Tue, 10 Mar 2015 14:38:54 GMT
Repository: maven
Updated Branches:
  refs/heads/master ab5f3a9de -> b7088a34e


MNG-5783 fixed slf4j is missing from ${plugin.artifacts}

Some plugins, e.g., cobertura-maven-plugin, use ${plugin.artifacts}
to setup classpath of externally launched jvms and they expect slf4j
to be available among plugin dependencies. At the same time slf4j
is already part of maven core runtime and it needs to be filtered
out from plugin and build extension realms to avoid duplicate classes
on classpath.

The fix is to move core artifact filtering from plugin dependency
resolver to class realm manager. This way ${plugin.artifacts} still
includes all compile/runtime scoped plugin dependencies but runtime
classpath only has plugin unique artifacts.

Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/b7088a34
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/b7088a34
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/b7088a34

Branch: refs/heads/master
Commit: b7088a34edd8cd34ab3b376d9baf90bdb6f8dc00
Parents: ab5f3a9
Author: Igor Fedorenko <ifedorenko@apache.org>
Authored: Tue Mar 10 09:40:36 2015 -0400
Committer: Igor Fedorenko <ifedorenko@apache.org>
Committed: Tue Mar 10 10:07:29 2015 -0400

----------------------------------------------------------------------
 .../classrealm/DefaultClassRealmManager.java    | 22 +++++++++++++++++---
 .../DefaultPluginDependenciesResolver.java      | 10 +--------
 2 files changed, 20 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/b7088a34/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
index 38e117f..69ee04a 100644
--- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
+++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
@@ -83,6 +83,12 @@ public class DefaultClassRealmManager
 
     private final ClassRealm mavenApiRealm;
 
+    /**
+     * Patterns of artifacts provided by maven core and exported via maven api realm. These
artifacts are filtered from
+     * plugin and build extensions realms to avoid presence of duplicate and possibly conflicting
classes on classpath.
+     */
+    private final Set<String> providedArtifacts;
+
     @Inject
     public DefaultClassRealmManager( Logger logger, PlexusContainer container,
                                      List<ClassRealmManagerDelegate> delegates, CoreExportsProvider
exports )
@@ -97,6 +103,8 @@ public class DefaultClassRealmManager
         this.mavenApiRealm =
             createRealm( API_REALMID, RealmType.Core, null /* parent */, null /* parentImports
*/, 
                          foreignImports, null /* artifacts */ );
+
+        this.providedArtifacts = exports.get().getExportedArtifacts();
     }
 
     private ClassRealm newRealm( String id )
@@ -156,10 +164,13 @@ public class DefaultClassRealmManager
         {
             for ( Artifact artifact : artifacts )
             {
-                artifactIds.add( getId( artifact ) );
-                if ( artifact.getFile() != null )
+                if ( !isProvidedArtifact( artifact ) )
                 {
-                    constituents.add( new ArtifactClassRealmConstituent( artifact ) );
+                    artifactIds.add( getId( artifact ) );
+                    if ( artifact.getFile() != null )
+                    {
+                        constituents.add( new ArtifactClassRealmConstituent( artifact ) );
+                    }
                 }
             }
         }
@@ -245,6 +256,11 @@ public class DefaultClassRealmManager
         return createRealm( getKey( plugin, true ), RealmType.Extension, parent, null, foreignImports,
artifacts );
     }
 
+    private boolean isProvidedArtifact( Artifact artifact )
+    {
+        return providedArtifacts.contains( artifact.getGroupId() + ":" + artifact.getArtifactId()
);
+    }
+
     public ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List<String>
parentImports,
                                          Map<String, ClassLoader> foreignImports, List<Artifact>
artifacts )
     {

http://git-wip-us.apache.org/repos/asf/maven/blob/b7088a34/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
index 9a9a7b8..5b0c271 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java
@@ -23,7 +23,6 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.maven.ArtifactFilterManager;
 import org.apache.maven.RepositoryUtils;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Plugin;
@@ -54,7 +53,6 @@ import org.eclipse.aether.resolution.DependencyRequest;
 import org.eclipse.aether.resolution.DependencyResolutionException;
 import org.eclipse.aether.util.artifact.JavaScopes;
 import org.eclipse.aether.util.filter.AndDependencyFilter;
-import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
 import org.eclipse.aether.util.filter.ScopeDependencyFilter;
 import org.eclipse.aether.util.graph.selector.AndDependencySelector;
 import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
@@ -79,9 +77,6 @@ public class DefaultPluginDependenciesResolver
     private Logger logger;
 
     @Requirement
-    private ArtifactFilterManager artifactFilterManager;
-
-    @Requirement
     private RepositorySystem repoSystem;
 
     private Artifact toArtifact( Plugin plugin, RepositorySystemSession session )
@@ -151,10 +146,7 @@ public class DefaultPluginDependenciesResolver
                                    List<RemoteRepository> repositories, RepositorySystemSession
session )
         throws PluginResolutionException
     {
-        DependencyFilter resolutionFilter =
-            new ExclusionsDependencyFilter( artifactFilterManager.getCoreArtifactExcludes()
);
-        resolutionFilter = AndDependencyFilter.newInstance( resolutionFilter, dependencyFilter
);
-        return resolveInternal( plugin, pluginArtifact, resolutionFilter, new PlexusUtilsInjector(),
repositories,
+        return resolveInternal( plugin, pluginArtifact, dependencyFilter, new PlexusUtilsInjector(),
repositories,
                                 session );
     }
 


Mime
View raw message