1 package org.apache.maven.plugin.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.eclipse.aether.RepositoryException;
23 import org.eclipse.aether.artifact.Artifact;
24 import org.eclipse.aether.artifact.DefaultArtifact;
25 import org.eclipse.aether.collection.DependencyGraphTransformationContext;
26 import org.eclipse.aether.collection.DependencyGraphTransformer;
27 import org.eclipse.aether.graph.DefaultDependencyNode;
28 import org.eclipse.aether.graph.Dependency;
29 import org.eclipse.aether.graph.DependencyNode;
30 import org.eclipse.aether.util.artifact.JavaScopes;
31
32
33
34
35
36
37
38 class PlexusUtilsInjector
39 implements DependencyGraphTransformer
40 {
41
42 private static final String GID = "org.codehaus.plexus";
43
44 private static final String AID = "plexus-utils";
45
46 private static final String VER = "1.1";
47
48 private static final String EXT = "jar";
49
50 public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
51 throws RepositoryException
52 {
53 if ( findPlexusUtils( node ) == null )
54 {
55 Artifact pu = new DefaultArtifact( GID, AID, null, EXT, VER );
56 DefaultDependencyNode child = new DefaultDependencyNode( new Dependency( pu, JavaScopes.RUNTIME ) );
57 child.setRepositories( node.getRepositories() );
58 child.setRequestContext( node.getRequestContext() );
59 node.getChildren().add( child );
60 }
61
62 return node;
63 }
64
65 private DependencyNode findPlexusUtils( DependencyNode node )
66 {
67 Artifact artifact = node.getDependency().getArtifact();
68
69 if ( AID.equals( artifact.getArtifactId() ) && GID.equals( artifact.getGroupId() )
70 && EXT.equals( artifact.getExtension() ) && "".equals( artifact.getClassifier() ) )
71 {
72 return node;
73 }
74
75 for ( DependencyNode child : node.getChildren() )
76 {
77 DependencyNode result = findPlexusUtils( child );
78 if ( result != null )
79 {
80 return result;
81 }
82 }
83
84 return null;
85 }
86
87 }