1 | |
package org.apache.maven.plugin; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.MavenArtifactFilterManager; |
23 | |
import org.apache.maven.artifact.Artifact; |
24 | |
import org.apache.maven.artifact.factory.ArtifactFactory; |
25 | |
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; |
26 | |
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; |
27 | |
import org.apache.maven.artifact.metadata.ResolutionGroup; |
28 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
29 | |
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; |
30 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionException; |
31 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; |
32 | |
import org.apache.maven.artifact.resolver.ArtifactResolver; |
33 | |
import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; |
34 | |
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; |
35 | |
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; |
36 | |
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; |
37 | |
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; |
38 | |
import org.apache.maven.artifact.versioning.VersionRange; |
39 | |
import org.apache.maven.execution.MavenSession; |
40 | |
import org.apache.maven.execution.RuntimeInformation; |
41 | |
import org.apache.maven.model.Plugin; |
42 | |
import org.apache.maven.model.ReportPlugin; |
43 | |
import org.apache.maven.monitor.event.EventDispatcher; |
44 | |
import org.apache.maven.monitor.event.MavenEvents; |
45 | |
import org.apache.maven.monitor.logging.DefaultLog; |
46 | |
import org.apache.maven.plugin.descriptor.MojoDescriptor; |
47 | |
import org.apache.maven.plugin.descriptor.Parameter; |
48 | |
import org.apache.maven.plugin.descriptor.PluginDescriptor; |
49 | |
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; |
50 | |
import org.apache.maven.plugin.logging.Log; |
51 | |
import org.apache.maven.plugin.version.PluginVersionManager; |
52 | |
import org.apache.maven.plugin.version.PluginVersionNotFoundException; |
53 | |
import org.apache.maven.plugin.version.PluginVersionResolutionException; |
54 | |
import org.apache.maven.project.MavenProject; |
55 | |
import org.apache.maven.project.MavenProjectBuilder; |
56 | |
import org.apache.maven.project.ProjectBuildingException; |
57 | |
import org.apache.maven.project.artifact.InvalidDependencyVersionException; |
58 | |
import org.apache.maven.project.artifact.MavenMetadataSource; |
59 | |
import org.apache.maven.project.path.PathTranslator; |
60 | |
import org.apache.maven.reporting.MavenReport; |
61 | |
import org.apache.maven.settings.Settings; |
62 | |
import org.codehaus.classworlds.ClassRealm; |
63 | |
import org.codehaus.classworlds.NoSuchRealmException; |
64 | |
import org.codehaus.plexus.PlexusConstants; |
65 | |
import org.codehaus.plexus.PlexusContainer; |
66 | |
import org.codehaus.plexus.PlexusContainerException; |
67 | |
import org.codehaus.plexus.component.configurator.ComponentConfigurationException; |
68 | |
import org.codehaus.plexus.component.configurator.ComponentConfigurator; |
69 | |
import org.codehaus.plexus.component.configurator.ConfigurationListener; |
70 | |
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; |
71 | |
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; |
72 | |
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; |
73 | |
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; |
74 | |
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; |
75 | |
import org.codehaus.plexus.configuration.PlexusConfiguration; |
76 | |
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; |
77 | |
import org.codehaus.plexus.context.Context; |
78 | |
import org.codehaus.plexus.context.ContextException; |
79 | |
import org.codehaus.plexus.logging.AbstractLogEnabled; |
80 | |
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; |
81 | |
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; |
82 | |
import org.codehaus.plexus.util.StringUtils; |
83 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
84 | |
|
85 | |
import java.io.File; |
86 | |
import java.net.URL; |
87 | |
import java.util.ArrayList; |
88 | |
import java.util.Arrays; |
89 | |
import java.util.Collection; |
90 | |
import java.util.Collections; |
91 | |
import java.util.HashMap; |
92 | |
import java.util.HashSet; |
93 | |
import java.util.Iterator; |
94 | |
import java.util.LinkedHashMap; |
95 | |
import java.util.LinkedHashSet; |
96 | |
import java.util.List; |
97 | |
import java.util.Map; |
98 | |
import java.util.Set; |
99 | |
|
100 | |
public class DefaultPluginManager |
101 | |
extends AbstractLogEnabled |
102 | |
implements PluginManager, Initializable, Contextualizable |
103 | |
{ |
104 | |
protected PlexusContainer container; |
105 | |
|
106 | |
protected PluginDescriptorBuilder pluginDescriptorBuilder; |
107 | |
|
108 | |
protected ArtifactFilter artifactFilter; |
109 | |
|
110 | |
private Log mojoLogger; |
111 | |
|
112 | 0 | private Map resolvedCoreArtifactFiles = new HashMap(); |
113 | |
|
114 | |
|
115 | |
protected PathTranslator pathTranslator; |
116 | |
|
117 | |
protected MavenPluginCollector pluginCollector; |
118 | |
|
119 | |
protected PluginVersionManager pluginVersionManager; |
120 | |
|
121 | |
protected ArtifactFactory artifactFactory; |
122 | |
|
123 | |
protected ArtifactResolver artifactResolver; |
124 | |
|
125 | |
protected ArtifactMetadataSource artifactMetadataSource; |
126 | |
|
127 | |
protected RuntimeInformation runtimeInformation; |
128 | |
|
129 | |
protected MavenProjectBuilder mavenProjectBuilder; |
130 | |
|
131 | |
protected PluginMappingManager pluginMappingManager; |
132 | |
|
133 | |
|
134 | |
|
135 | |
public DefaultPluginManager() |
136 | 0 | { |
137 | 0 | pluginDescriptorBuilder = new PluginDescriptorBuilder(); |
138 | 0 | } |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) |
145 | |
{ |
146 | 0 | return pluginCollector.getPluginDescriptorForPrefix( prefix ); |
147 | |
} |
148 | |
|
149 | |
public Plugin getPluginDefinitionForPrefix( String prefix, |
150 | |
MavenSession session, |
151 | |
MavenProject project ) |
152 | |
{ |
153 | |
|
154 | |
|
155 | 0 | return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(), |
156 | |
project.getPluginArtifactRepositories(), |
157 | |
session.getLocalRepository() ); |
158 | |
} |
159 | |
|
160 | |
public PluginDescriptor verifyPlugin( Plugin plugin, |
161 | |
MavenProject project, |
162 | |
Settings settings, |
163 | |
ArtifactRepository localRepository ) |
164 | |
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, |
165 | |
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, |
166 | |
PluginVersionNotFoundException |
167 | |
{ |
168 | |
|
169 | |
|
170 | 0 | if ( plugin.getVersion() == null ) |
171 | |
{ |
172 | 0 | String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(), |
173 | |
project, settings, localRepository ); |
174 | 0 | plugin.setVersion( version ); |
175 | |
} |
176 | |
|
177 | 0 | return verifyVersionedPlugin( plugin, project, localRepository ); |
178 | |
} |
179 | |
|
180 | |
private PluginDescriptor verifyVersionedPlugin( Plugin plugin, |
181 | |
MavenProject project, |
182 | |
ArtifactRepository localRepository ) |
183 | |
throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException, |
184 | |
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException |
185 | |
{ |
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
try |
191 | |
{ |
192 | 0 | VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() ); |
193 | |
|
194 | 0 | List remoteRepositories = new ArrayList(); |
195 | 0 | remoteRepositories.addAll( project.getPluginArtifactRepositories() ); |
196 | 0 | remoteRepositories.addAll( project.getRemoteArtifactRepositories() ); |
197 | |
|
198 | 0 | checkRequiredMavenVersion( plugin, localRepository, remoteRepositories ); |
199 | |
|
200 | 0 | Artifact pluginArtifact = |
201 | |
artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); |
202 | |
|
203 | 0 | pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact ); |
204 | |
|
205 | 0 | artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository ); |
206 | |
|
207 | 0 | plugin.setVersion( pluginArtifact.getBaseVersion() ); |
208 | |
|
209 | 0 | String pluginKey = PluginUtils.constructVersionedKey( plugin ); |
210 | |
|
211 | 0 | PlexusContainer pluginContainer = container.getChildContainer( pluginKey ); |
212 | |
|
213 | 0 | File pluginFile = pluginArtifact.getFile(); |
214 | |
|
215 | 0 | if ( !pluginCollector.isPluginInstalled( plugin ) || ( pluginContainer == null ) ) |
216 | |
{ |
217 | 0 | addPlugin( plugin, pluginArtifact, project, localRepository ); |
218 | |
} |
219 | 0 | else if ( pluginFile.lastModified() > pluginContainer.getCreationDate().getTime() ) |
220 | |
{ |
221 | 0 | getLogger().info( |
222 | |
"Reloading plugin container for: " + pluginKey + ". The plugin artifact has changed." ); |
223 | |
|
224 | 0 | pluginContainer.dispose(); |
225 | |
|
226 | 0 | pluginCollector.flushPluginDescriptor( plugin ); |
227 | |
|
228 | 0 | addPlugin( plugin, pluginArtifact, project, localRepository ); |
229 | |
} |
230 | |
|
231 | 0 | project.addPlugin( plugin ); |
232 | |
} |
233 | 0 | catch ( ArtifactNotFoundException e ) |
234 | |
{ |
235 | 0 | String groupId = plugin.getGroupId(); |
236 | 0 | String artifactId = plugin.getArtifactId(); |
237 | 0 | String version = plugin.getVersion(); |
238 | |
|
239 | 0 | if ( ( groupId == null ) || ( artifactId == null ) || ( version == null ) ) |
240 | |
{ |
241 | 0 | throw new PluginNotFoundException( e ); |
242 | |
} |
243 | 0 | else if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) && |
244 | |
version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) ) |
245 | |
{ |
246 | 0 | throw new PluginNotFoundException( e ); |
247 | |
} |
248 | |
else |
249 | |
{ |
250 | 0 | throw e; |
251 | |
} |
252 | 0 | } |
253 | |
|
254 | 0 | return pluginCollector.getPluginDescriptor( plugin ); |
255 | |
} |
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
private void checkRequiredMavenVersion( Plugin plugin, |
262 | |
ArtifactRepository localRepository, |
263 | |
List remoteRepositories ) |
264 | |
throws PluginVersionResolutionException, InvalidPluginException |
265 | |
{ |
266 | |
try |
267 | |
{ |
268 | 0 | Artifact artifact = artifactFactory.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(), |
269 | |
plugin.getVersion() ); |
270 | 0 | MavenProject project = |
271 | |
mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository, false ); |
272 | |
|
273 | 0 | if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) ) |
274 | |
{ |
275 | 0 | DefaultArtifactVersion requiredVersion = |
276 | |
new DefaultArtifactVersion( project.getPrerequisites().getMaven() ); |
277 | 0 | if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 ) |
278 | |
{ |
279 | 0 | throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(), |
280 | |
"Plugin requires Maven version " + requiredVersion ); |
281 | |
} |
282 | |
} |
283 | |
} |
284 | 0 | catch ( ProjectBuildingException e ) |
285 | |
{ |
286 | 0 | throw new InvalidPluginException( |
287 | |
"Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); |
288 | 0 | } |
289 | 0 | } |
290 | |
|
291 | |
protected void addPlugin( Plugin plugin, |
292 | |
Artifact pluginArtifact, |
293 | |
MavenProject project, |
294 | |
ArtifactRepository localRepository ) |
295 | |
throws PluginManagerException, InvalidPluginException |
296 | |
{ |
297 | |
PlexusContainer child; |
298 | |
|
299 | |
try |
300 | |
{ |
301 | 0 | MavenPluginValidator validator = new MavenPluginValidator( pluginArtifact ); |
302 | |
|
303 | 0 | String key = PluginUtils.constructVersionedKey( plugin ).intern(); |
304 | 0 | child = container.createChildContainer( key, |
305 | |
Collections.singletonList( pluginArtifact.getFile() ), |
306 | |
Collections.EMPTY_MAP, |
307 | |
Arrays.asList( new ComponentDiscoveryListener[] { validator, pluginCollector } ) ); |
308 | |
|
309 | |
|
310 | |
|
311 | 0 | child.removeComponentDiscoveryListener( validator ); |
312 | 0 | child.removeComponentDiscoveryListener( pluginCollector ); |
313 | |
|
314 | 0 | if ( validator.hasErrors() ) |
315 | |
{ |
316 | 0 | String msg = "Plugin '" + key + "' has an invalid descriptor:"; |
317 | 0 | int count = 1; |
318 | 0 | for ( Iterator i = validator.getErrors().iterator(); i.hasNext(); ) |
319 | |
{ |
320 | 0 | msg += "\n" + count + ") " + i.next(); |
321 | 0 | count++; |
322 | |
} |
323 | 0 | throw new PluginManagerException( msg ); |
324 | |
} |
325 | |
|
326 | |
try |
327 | |
{ |
328 | 0 | child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.Xpp3Dom" ); |
329 | 0 | child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlPullParser" ); |
330 | 0 | child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlPullParserException" ); |
331 | 0 | child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlSerializer" ); |
332 | |
|
333 | |
|
334 | 0 | child.getContainerRealm().importFrom( "plexus.core", "/default-report.xml" ); |
335 | |
} |
336 | 0 | catch ( NoSuchRealmException e ) |
337 | |
{ |
338 | |
|
339 | 0 | } |
340 | |
} |
341 | 0 | catch ( PlexusContainerException e ) |
342 | |
{ |
343 | 0 | throw new PluginManagerException( |
344 | |
"Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e ); |
345 | 0 | } |
346 | |
|
347 | |
|
348 | |
|
349 | 0 | PluginDescriptor addedPlugin = pluginCollector.getPluginDescriptor( plugin ); |
350 | |
|
351 | 0 | if ( addedPlugin == null ) |
352 | |
{ |
353 | 0 | throw new IllegalStateException( "The plugin descriptor for the plugin " + plugin + " was not found." |
354 | |
+ " Please verify that the plugin JAR " + pluginArtifact.getFile() + " is intact." ); |
355 | |
} |
356 | |
|
357 | 0 | addedPlugin.setClassRealm( child.getContainerRealm() ); |
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | 0 | addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) ); |
363 | 0 | addedPlugin.setPluginArtifact( pluginArtifact ); |
364 | |
|
365 | |
try |
366 | |
{ |
367 | |
|
368 | |
|
369 | |
|
370 | 0 | Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() ); |
371 | |
|
372 | 0 | if ( projectPlugin == null ) |
373 | |
{ |
374 | 0 | projectPlugin = plugin; |
375 | |
} |
376 | |
|
377 | 0 | Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, projectPlugin.getDependencies(), null, |
378 | |
null, project ); |
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | 0 | addedPlugin.setIntroducedDependencyArtifacts( artifacts ); |
384 | |
} |
385 | 0 | catch ( InvalidDependencyVersionException e ) |
386 | |
{ |
387 | 0 | throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e ); |
388 | 0 | } |
389 | 0 | } |
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
public void executeMojo( MavenProject project, |
396 | |
MojoExecution mojoExecution, |
397 | |
MavenSession session ) |
398 | |
throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException, |
399 | |
InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException |
400 | |
{ |
401 | 0 | MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); |
402 | |
|
403 | |
|
404 | |
|
405 | 0 | if ( mojoDescriptor.isProjectRequired() && !session.isUsingPOMsFromFilesystem() ) |
406 | |
{ |
407 | 0 | throw new MojoExecutionException( "Cannot execute mojo: " + mojoDescriptor.getGoal() + |
408 | |
". It requires a project with an existing pom.xml, but the build is not using one." ); |
409 | |
} |
410 | |
|
411 | 0 | if ( mojoDescriptor.isOnlineRequired() && session.getSettings().isOffline() ) |
412 | |
{ |
413 | |
|
414 | 0 | throw new MojoExecutionException( "Mojo: " + mojoDescriptor.getGoal() + |
415 | |
" requires online mode for execution. Maven is currently offline." ); |
416 | |
} |
417 | |
|
418 | 0 | if ( mojoDescriptor.isDependencyResolutionRequired() != null ) |
419 | |
{ |
420 | |
Collection projects; |
421 | |
|
422 | 0 | if ( mojoDescriptor.isAggregator() ) |
423 | |
{ |
424 | 0 | projects = session.getSortedProjects(); |
425 | |
} |
426 | |
else |
427 | |
{ |
428 | 0 | projects = Collections.singleton( project ); |
429 | |
} |
430 | |
|
431 | 0 | for ( Iterator i = projects.iterator(); i.hasNext(); ) |
432 | |
{ |
433 | 0 | MavenProject p = (MavenProject) i.next(); |
434 | |
|
435 | 0 | resolveTransitiveDependencies( session, artifactResolver, |
436 | |
mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p, mojoDescriptor.isAggregator() ); |
437 | 0 | } |
438 | |
|
439 | 0 | downloadDependencies( project, session, artifactResolver ); |
440 | |
} |
441 | |
|
442 | 0 | String goalName = mojoDescriptor.getFullGoalName(); |
443 | |
|
444 | |
Mojo plugin; |
445 | |
|
446 | 0 | PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); |
447 | |
|
448 | 0 | String goalId = mojoDescriptor.getGoal(); |
449 | 0 | String groupId = pluginDescriptor.getGroupId(); |
450 | 0 | String artifactId = pluginDescriptor.getArtifactId(); |
451 | 0 | String executionId = mojoExecution.getExecutionId(); |
452 | |
|
453 | 0 | Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId ); |
454 | 0 | Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId ); |
455 | 0 | dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom ); |
456 | 0 | if ( mojoExecution.getConfiguration() != null ) |
457 | |
{ |
458 | 0 | dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); |
459 | |
} |
460 | |
|
461 | 0 | plugin = getConfiguredMojo( session, dom, project, false, mojoExecution ); |
462 | |
|
463 | |
|
464 | 0 | String event = MavenEvents.MOJO_EXECUTION; |
465 | 0 | EventDispatcher dispatcher = session.getEventDispatcher(); |
466 | |
|
467 | 0 | String goalExecId = goalName; |
468 | |
|
469 | 0 | if ( mojoExecution.getExecutionId() != null ) |
470 | |
{ |
471 | 0 | goalExecId += " {execution: " + mojoExecution.getExecutionId() + "}"; |
472 | |
} |
473 | |
|
474 | 0 | dispatcher.dispatchStart( event, goalExecId ); |
475 | |
|
476 | 0 | ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); |
477 | |
|
478 | |
try |
479 | |
{ |
480 | 0 | Thread.currentThread().setContextClassLoader( |
481 | |
mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader() ); |
482 | |
|
483 | 0 | plugin.execute(); |
484 | |
|
485 | 0 | dispatcher.dispatchEnd( event, goalExecId ); |
486 | |
} |
487 | 0 | catch ( MojoExecutionException e ) |
488 | |
{ |
489 | 0 | session.getEventDispatcher().dispatchError( event, goalExecId, e ); |
490 | |
|
491 | 0 | throw e; |
492 | |
} |
493 | 0 | catch ( MojoFailureException e ) |
494 | |
{ |
495 | 0 | session.getEventDispatcher().dispatchError( event, goalExecId, e ); |
496 | |
|
497 | 0 | throw e; |
498 | |
} |
499 | 0 | catch ( LinkageError e ) |
500 | |
{ |
501 | 0 | if ( getLogger().isFatalErrorEnabled() ) |
502 | |
{ |
503 | 0 | getLogger().fatalError( |
504 | |
plugin.getClass().getName() + "#execute() caused a linkage error (" |
505 | |
+ e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); |
506 | |
|
507 | 0 | ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); |
508 | 0 | StringBuffer sb = new StringBuffer(); |
509 | 0 | sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); |
510 | 0 | for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) |
511 | |
{ |
512 | 0 | sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); |
513 | 0 | if ( i != ( pluginRealm.getConstituents().length - 1 ) ) |
514 | |
{ |
515 | 0 | sb.append( '\n' ); |
516 | |
} |
517 | |
} |
518 | 0 | getLogger().fatalError( sb.toString() ); |
519 | |
|
520 | 0 | ClassRealm containerRealm = container.getContainerRealm(); |
521 | 0 | sb = new StringBuffer(); |
522 | 0 | sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); |
523 | 0 | for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) |
524 | |
{ |
525 | 0 | sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); |
526 | 0 | if ( i != ( containerRealm.getConstituents().length - 1 ) ) |
527 | |
{ |
528 | 0 | sb.append( '\n' ); |
529 | |
} |
530 | |
} |
531 | 0 | getLogger().fatalError( sb.toString() ); |
532 | |
} |
533 | |
|
534 | 0 | session.getEventDispatcher().dispatchError( event, goalExecId, e ); |
535 | |
|
536 | 0 | throw e; |
537 | |
} |
538 | |
finally |
539 | |
{ |
540 | |
|
541 | 0 | Thread.currentThread().setContextClassLoader( oldClassLoader ); |
542 | |
|
543 | |
try |
544 | |
{ |
545 | 0 | PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() ); |
546 | |
|
547 | 0 | pluginContainer.release( plugin ); |
548 | |
} |
549 | 0 | catch ( ComponentLifecycleException e ) |
550 | |
{ |
551 | 0 | if ( getLogger().isErrorEnabled() ) |
552 | |
{ |
553 | 0 | getLogger().error( "Error releasing plugin - ignoring.", e ); |
554 | |
} |
555 | 0 | } |
556 | 0 | } |
557 | 0 | } |
558 | |
|
559 | |
|
560 | |
public MavenReport getReport( MavenProject project, |
561 | |
MojoExecution mojoExecution, |
562 | |
MavenSession session ) |
563 | |
throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException, |
564 | |
ArtifactResolutionException |
565 | |
{ |
566 | 0 | MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); |
567 | 0 | PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor(); |
568 | |
|
569 | 0 | Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(), |
570 | |
mojoExecution.getExecutionId() ); |
571 | 0 | if ( mojoExecution.getConfiguration() != null ) |
572 | |
{ |
573 | 0 | dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); |
574 | |
} |
575 | |
|
576 | 0 | MavenReport report = (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution ); |
577 | |
|
578 | 0 | return report; |
579 | |
} |
580 | |
|
581 | |
public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, |
582 | |
MavenProject project, |
583 | |
MavenSession session ) |
584 | |
throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException, |
585 | |
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, |
586 | |
PluginVersionNotFoundException |
587 | |
{ |
588 | 0 | String version = reportPlugin.getVersion(); |
589 | |
|
590 | 0 | if ( version == null ) |
591 | |
{ |
592 | 0 | version = pluginVersionManager.resolveReportPluginVersion( reportPlugin.getGroupId(), |
593 | |
reportPlugin.getArtifactId(), project, |
594 | |
session.getSettings(), |
595 | |
session.getLocalRepository() ); |
596 | 0 | reportPlugin.setVersion( version ); |
597 | |
} |
598 | |
|
599 | 0 | Plugin forLookup = new Plugin(); |
600 | |
|
601 | 0 | forLookup.setGroupId( reportPlugin.getGroupId() ); |
602 | 0 | forLookup.setArtifactId( reportPlugin.getArtifactId() ); |
603 | 0 | forLookup.setVersion( version ); |
604 | |
|
605 | 0 | return verifyVersionedPlugin( forLookup, project, session.getLocalRepository() ); |
606 | |
} |
607 | |
|
608 | |
private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor ) |
609 | |
throws PluginManagerException |
610 | |
{ |
611 | 0 | String pluginKey = PluginUtils.constructVersionedKey( pluginDescriptor ); |
612 | |
|
613 | 0 | PlexusContainer pluginContainer = container.getChildContainer( pluginKey ); |
614 | |
|
615 | 0 | if ( pluginContainer == null ) |
616 | |
{ |
617 | 0 | throw new PluginManagerException( "Cannot find Plexus container for plugin: " + pluginKey ); |
618 | |
} |
619 | |
|
620 | 0 | return pluginContainer; |
621 | |
} |
622 | |
|
623 | |
private Mojo getConfiguredMojo( MavenSession session, |
624 | |
Xpp3Dom dom, |
625 | |
MavenProject project, |
626 | |
boolean report, |
627 | |
MojoExecution mojoExecution ) |
628 | |
throws PluginConfigurationException, ArtifactNotFoundException, PluginManagerException, |
629 | |
ArtifactResolutionException |
630 | |
{ |
631 | 0 | MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); |
632 | |
|
633 | 0 | PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); |
634 | |
|
635 | 0 | PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); |
636 | |
|
637 | |
|
638 | |
|
639 | |
|
640 | 0 | ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session ); |
641 | |
|
642 | |
Mojo plugin; |
643 | |
try |
644 | |
{ |
645 | 0 | plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() ); |
646 | 0 | if ( report && !( plugin instanceof MavenReport ) ) |
647 | |
{ |
648 | |
|
649 | 0 | return null; |
650 | |
} |
651 | |
} |
652 | 0 | catch ( ComponentLookupException e ) |
653 | |
{ |
654 | 0 | Throwable cause = e.getCause(); |
655 | 0 | while( cause != null && !(cause instanceof NoClassDefFoundError ) ) |
656 | |
{ |
657 | 0 | cause = cause.getCause(); |
658 | |
} |
659 | |
|
660 | 0 | if ( cause != null && ( cause instanceof NoClassDefFoundError ) ) |
661 | |
{ |
662 | 0 | throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint() |
663 | |
+ "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: " |
664 | |
+ cause.getMessage(), e ); |
665 | |
} |
666 | |
|
667 | 0 | throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getGoal() + |
668 | |
"' (or one of its required components) in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e ); |
669 | |
} |
670 | 0 | catch ( NoClassDefFoundError e ) |
671 | |
{ |
672 | 0 | throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint() |
673 | |
+ "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: " |
674 | |
+ e.getMessage(), e ); |
675 | 0 | } |
676 | |
|
677 | 0 | if ( plugin instanceof ContextEnabled ) |
678 | |
{ |
679 | 0 | Map pluginContext = session.getPluginContext( pluginDescriptor, project ); |
680 | |
|
681 | 0 | ( (ContextEnabled) plugin ).setPluginContext( pluginContext ); |
682 | |
} |
683 | |
|
684 | 0 | plugin.setLog( mojoLogger ); |
685 | |
|
686 | |
XmlPlexusConfiguration pomConfiguration; |
687 | 0 | if ( dom == null ) |
688 | |
{ |
689 | 0 | pomConfiguration = new XmlPlexusConfiguration( "configuration" ); |
690 | |
} |
691 | |
else |
692 | |
{ |
693 | 0 | pomConfiguration = new XmlPlexusConfiguration( dom ); |
694 | |
} |
695 | |
|
696 | |
|
697 | |
|
698 | 0 | validatePomConfiguration( mojoDescriptor, pomConfiguration ); |
699 | |
|
700 | 0 | PlexusConfiguration mergedConfiguration = mergeMojoConfiguration( pomConfiguration, mojoDescriptor ); |
701 | |
|
702 | |
|
703 | |
|
704 | |
|
705 | |
|
706 | 0 | ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution, |
707 | |
pathTranslator, |
708 | |
getLogger(), |
709 | |
project, |
710 | |
session.getExecutionProperties() ); |
711 | |
|
712 | 0 | PlexusConfiguration extractedMojoConfiguration = |
713 | |
extractMojoConfiguration( mergedConfiguration, mojoDescriptor ); |
714 | |
|
715 | 0 | checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator ); |
716 | |
|
717 | 0 | populatePluginFields( plugin, mojoDescriptor, extractedMojoConfiguration, pluginContainer, |
718 | |
expressionEvaluator ); |
719 | 0 | return plugin; |
720 | |
} |
721 | |
|
722 | |
private void ensurePluginContainerIsComplete( PluginDescriptor pluginDescriptor, |
723 | |
PlexusContainer pluginContainer, |
724 | |
MavenProject project, |
725 | |
MavenSession session ) |
726 | |
throws ArtifactNotFoundException, PluginManagerException, ArtifactResolutionException |
727 | |
{ |
728 | |
|
729 | |
|
730 | 0 | if ( ( pluginDescriptor.getArtifacts() != null ) && ( pluginDescriptor.getArtifacts().size() == 1 ) ) |
731 | |
{ |
732 | 0 | Artifact pluginArtifact = (Artifact) pluginDescriptor.getArtifacts().get( 0 ); |
733 | |
|
734 | 0 | ArtifactRepository localRepository = session.getLocalRepository(); |
735 | |
|
736 | |
ResolutionGroup resolutionGroup; |
737 | |
try |
738 | |
{ |
739 | 0 | resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository, |
740 | |
project.getPluginArtifactRepositories() ); |
741 | |
} |
742 | 0 | catch ( ArtifactMetadataRetrievalException e ) |
743 | |
{ |
744 | 0 | throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" + |
745 | |
pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e ); |
746 | 0 | } |
747 | |
|
748 | 0 | Set rgArtifacts = resolutionGroup.getArtifacts(); |
749 | |
|
750 | 0 | rgArtifacts = checkPlexusUtils( rgArtifacts, artifactFactory ); |
751 | |
|
752 | |
|
753 | |
|
754 | |
|
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | 0 | Map dependencyMap = new LinkedHashMap(); |
770 | |
|
771 | |
|
772 | |
|
773 | 0 | List all = new ArrayList(); |
774 | |
|
775 | |
|
776 | |
|
777 | 0 | all.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() ); |
778 | |
|
779 | |
|
780 | 0 | all.addAll( rgArtifacts ); |
781 | |
|
782 | 0 | for ( Iterator it = all.iterator(); it.hasNext(); ) |
783 | |
{ |
784 | 0 | Artifact artifact = (Artifact) it.next(); |
785 | 0 | String conflictId = artifact.getDependencyConflictId(); |
786 | |
|
787 | |
|
788 | |
|
789 | |
|
790 | 0 | if ( !dependencyMap.containsKey( conflictId ) ) |
791 | |
{ |
792 | 0 | dependencyMap.put( conflictId, artifact ); |
793 | |
} |
794 | 0 | } |
795 | |
|
796 | |
|
797 | 0 | Set dependencies = new LinkedHashSet( dependencyMap.values() ); |
798 | |
|
799 | 0 | if ( getLogger().isDebugEnabled() ) |
800 | |
{ |
801 | |
|
802 | 0 | getLogger().debug( "Plugin dependencies for:\n\n" + pluginDescriptor.getId() |
803 | |
+ "\n\nare:\n\n" |
804 | |
+ StringUtils.join( dependencies.iterator(), "\n" ) + "\n\n" ); |
805 | |
} |
806 | |
|
807 | 0 | List repositories = new ArrayList(); |
808 | 0 | repositories.addAll( resolutionGroup.getResolutionRepositories() ); |
809 | 0 | repositories.addAll( project.getRemoteArtifactRepositories() ); |
810 | |
|
811 | |
|
812 | 0 | Map pluginManagedDependencies = new HashMap(); |
813 | |
try |
814 | |
{ |
815 | 0 | MavenProject pluginProject = |
816 | |
mavenProjectBuilder.buildFromRepository( pluginArtifact, project.getRemoteArtifactRepositories(), |
817 | |
localRepository ); |
818 | 0 | if ( pluginProject != null ) |
819 | |
{ |
820 | 0 | pluginManagedDependencies = pluginProject.getManagedVersionMap(); |
821 | |
} |
822 | |
} |
823 | 0 | catch ( ProjectBuildingException e ) |
824 | |
{ |
825 | |
|
826 | 0 | } |
827 | |
|
828 | 0 | ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact, |
829 | |
pluginManagedDependencies, |
830 | |
localRepository, repositories, |
831 | |
artifactMetadataSource, |
832 | |
artifactFilter ); |
833 | |
|
834 | 0 | Set resolved = result.getArtifacts(); |
835 | |
|
836 | 0 | for ( Iterator it = resolved.iterator(); it.hasNext(); ) |
837 | |
{ |
838 | 0 | Artifact artifact = (Artifact) it.next(); |
839 | |
|
840 | 0 | if ( !artifact.equals( pluginArtifact ) ) |
841 | |
{ |
842 | 0 | artifact = project.replaceWithActiveArtifact( artifact ); |
843 | |
|
844 | |
try |
845 | |
{ |
846 | 0 | pluginContainer.addJarResource( artifact.getFile() ); |
847 | |
} |
848 | 0 | catch ( PlexusContainerException e ) |
849 | |
{ |
850 | 0 | throw new PluginManagerException( "Error adding plugin dependency '" + |
851 | |
artifact.getDependencyConflictId() + "' into plugin manager: " + e.getMessage(), e ); |
852 | 0 | } |
853 | |
} |
854 | 0 | } |
855 | |
|
856 | 0 | pluginDescriptor.setClassRealm( pluginContainer.getContainerRealm() ); |
857 | |
|
858 | 0 | List unresolved = new ArrayList( dependencies ); |
859 | |
|
860 | 0 | unresolved.removeAll( resolved ); |
861 | |
|
862 | 0 | if ( getLogger().isDebugEnabled() ) |
863 | |
{ |
864 | |
|
865 | |
|
866 | 0 | getLogger().debug( " The following artifacts were filtered out for plugin: " |
867 | |
+ pluginDescriptor.getId() |
868 | |
+ " because they're already in the core of Maven:\n\n" |
869 | |
+ StringUtils.join( unresolved.iterator(), "\n" ) |
870 | |
+ "\n\nThese will use the artifact files already in the core ClassRealm instead, to allow them to be included in PluginDescriptor.getArtifacts().\n\n" ); |
871 | |
} |
872 | |
|
873 | |
|
874 | |
|
875 | |
|
876 | 0 | resolveCoreArtifacts( unresolved, localRepository, resolutionGroup.getResolutionRepositories() ); |
877 | |
|
878 | |
|
879 | |
|
880 | |
|
881 | |
|
882 | |
|
883 | 0 | List allResolved = new ArrayList( resolved.size() + unresolved.size() ); |
884 | |
|
885 | 0 | allResolved.addAll( resolved ); |
886 | 0 | allResolved.addAll( unresolved ); |
887 | |
|
888 | 0 | pluginDescriptor.setArtifacts( allResolved ); |
889 | |
} |
890 | 0 | } |
891 | |
|
892 | |
public static Set checkPlexusUtils( Set dependencyArtifacts, ArtifactFactory artifactFactory ) |
893 | |
{ |
894 | |
|
895 | |
|
896 | |
|
897 | |
|
898 | |
|
899 | |
|
900 | |
|
901 | |
|
902 | |
|
903 | |
|
904 | 0 | VersionRange vr = null; |
905 | |
|
906 | |
try |
907 | |
{ |
908 | 0 | vr = VersionRange.createFromVersionSpec( "[1.1,)" ); |
909 | |
} |
910 | 0 | catch ( InvalidVersionSpecificationException e ) |
911 | |
{ |
912 | |
|
913 | 0 | } |
914 | |
|
915 | 0 | boolean plexusUtilsPresent = false; |
916 | |
|
917 | 0 | for ( Iterator i = dependencyArtifacts.iterator(); i.hasNext(); ) |
918 | |
{ |
919 | 0 | Artifact a = (Artifact) i.next(); |
920 | |
|
921 | 0 | if ( a.getArtifactId().equals( "plexus-utils" ) && |
922 | |
vr.containsVersion( new DefaultArtifactVersion( a.getVersion() ) ) ) |
923 | |
{ |
924 | 0 | plexusUtilsPresent = true; |
925 | |
|
926 | 0 | break; |
927 | |
} |
928 | 0 | } |
929 | |
|
930 | 0 | if ( !plexusUtilsPresent ) |
931 | |
{ |
932 | |
|
933 | |
|
934 | |
|
935 | |
|
936 | 0 | Set result = new LinkedHashSet(); |
937 | 0 | if ( !dependencyArtifacts.isEmpty() ) |
938 | |
{ |
939 | 0 | result.addAll( dependencyArtifacts ); |
940 | |
} |
941 | |
|
942 | 0 | result.add( artifactFactory.createArtifact( "org.codehaus.plexus", "plexus-utils", "1.1", Artifact.SCOPE_RUNTIME, "jar" ) ); |
943 | |
|
944 | 0 | return result; |
945 | |
} |
946 | |
else |
947 | |
{ |
948 | 0 | return dependencyArtifacts; |
949 | |
} |
950 | |
} |
951 | |
|
952 | |
private void resolveCoreArtifacts( List unresolved, |
953 | |
ArtifactRepository localRepository, |
954 | |
List resolutionRepositories ) |
955 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
956 | |
{ |
957 | 0 | for ( Iterator it = unresolved.iterator(); it.hasNext(); ) |
958 | |
{ |
959 | 0 | Artifact artifact = (Artifact) it.next(); |
960 | |
|
961 | 0 | File artifactFile = (File) resolvedCoreArtifactFiles.get( artifact.getId() ); |
962 | |
|
963 | 0 | if ( artifactFile == null ) |
964 | |
{ |
965 | 0 | String resource = |
966 | |
"/META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml"; |
967 | |
|
968 | 0 | URL resourceUrl = container.getContainerRealm().getResource( resource ); |
969 | |
|
970 | 0 | if ( resourceUrl == null ) |
971 | |
{ |
972 | 0 | artifactResolver.resolve( artifact, resolutionRepositories, localRepository ); |
973 | |
|
974 | 0 | artifactFile = artifact.getFile(); |
975 | |
} |
976 | |
else |
977 | |
{ |
978 | 0 | String artifactPath = resourceUrl.getPath(); |
979 | |
|
980 | 0 | if ( artifactPath.startsWith( "file:" ) ) |
981 | |
{ |
982 | 0 | artifactPath = artifactPath.substring( "file:".length() ); |
983 | |
} |
984 | |
|
985 | 0 | artifactPath = artifactPath.substring( 0, artifactPath.length() - resource.length() ); |
986 | |
|
987 | 0 | if ( artifactPath.endsWith( "/" ) ) |
988 | |
{ |
989 | 0 | artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); |
990 | |
} |
991 | |
|
992 | 0 | if ( artifactPath.endsWith( "!" ) ) |
993 | |
{ |
994 | 0 | artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); |
995 | |
} |
996 | |
|
997 | 0 | artifactFile = new File( artifactPath ).getAbsoluteFile(); |
998 | |
} |
999 | |
|
1000 | 0 | resolvedCoreArtifactFiles.put( artifact.getId(), artifactFile ); |
1001 | |
} |
1002 | |
|
1003 | 0 | artifact.setFile( artifactFile ); |
1004 | 0 | } |
1005 | 0 | } |
1006 | |
|
1007 | |
private PlexusConfiguration extractMojoConfiguration( PlexusConfiguration mergedConfiguration, |
1008 | |
MojoDescriptor mojoDescriptor ) |
1009 | |
{ |
1010 | 0 | Map parameterMap = mojoDescriptor.getParameterMap(); |
1011 | |
|
1012 | 0 | PlexusConfiguration[] mergedChildren = mergedConfiguration.getChildren(); |
1013 | |
|
1014 | 0 | XmlPlexusConfiguration extractedConfiguration = new XmlPlexusConfiguration( "configuration" ); |
1015 | |
|
1016 | 0 | for ( int i = 0; i < mergedChildren.length; i++ ) |
1017 | |
{ |
1018 | 0 | PlexusConfiguration child = mergedChildren[i]; |
1019 | |
|
1020 | 0 | if ( parameterMap.containsKey( child.getName() ) ) |
1021 | |
{ |
1022 | 0 | extractedConfiguration.addChild( copyConfiguration( child ) ); |
1023 | |
} |
1024 | |
else |
1025 | |
{ |
1026 | |
|
1027 | |
|
1028 | |
|
1029 | |
|
1030 | 0 | getLogger().debug( "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" + |
1031 | |
mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" ); |
1032 | |
} |
1033 | |
} |
1034 | |
|
1035 | 0 | return extractedConfiguration; |
1036 | |
} |
1037 | |
|
1038 | |
private void checkRequiredParameters( MojoDescriptor goal, |
1039 | |
PlexusConfiguration configuration, |
1040 | |
ExpressionEvaluator expressionEvaluator ) |
1041 | |
throws PluginConfigurationException |
1042 | |
{ |
1043 | |
|
1044 | |
|
1045 | 0 | List parameters = goal.getParameters(); |
1046 | |
|
1047 | 0 | if ( parameters == null ) |
1048 | |
{ |
1049 | 0 | return; |
1050 | |
} |
1051 | |
|
1052 | 0 | List invalidParameters = new ArrayList(); |
1053 | |
|
1054 | 0 | for ( int i = 0; i < parameters.size(); i++ ) |
1055 | |
{ |
1056 | 0 | Parameter parameter = (Parameter) parameters.get( i ); |
1057 | |
|
1058 | 0 | if ( parameter.isRequired() ) |
1059 | |
{ |
1060 | |
|
1061 | 0 | String key = parameter.getName(); |
1062 | |
|
1063 | 0 | Object fieldValue = null; |
1064 | 0 | String expression = null; |
1065 | 0 | PlexusConfiguration value = configuration.getChild( key, false ); |
1066 | |
try |
1067 | |
{ |
1068 | 0 | if ( value != null ) |
1069 | |
{ |
1070 | 0 | expression = value.getValue( null ); |
1071 | |
|
1072 | 0 | fieldValue = expressionEvaluator.evaluate( expression ); |
1073 | |
|
1074 | 0 | if ( fieldValue == null ) |
1075 | |
{ |
1076 | 0 | fieldValue = value.getAttribute( "default-value", null ); |
1077 | |
} |
1078 | |
} |
1079 | |
|
1080 | 0 | if ( ( fieldValue == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) |
1081 | |
{ |
1082 | 0 | value = configuration.getChild( parameter.getAlias(), false ); |
1083 | 0 | if ( value != null ) |
1084 | |
{ |
1085 | 0 | expression = value.getValue( null ); |
1086 | 0 | fieldValue = expressionEvaluator.evaluate( expression ); |
1087 | 0 | if ( fieldValue == null ) |
1088 | |
{ |
1089 | 0 | fieldValue = value.getAttribute( "default-value", null ); |
1090 | |
} |
1091 | |
} |
1092 | |
} |
1093 | |
} |
1094 | 0 | catch ( ExpressionEvaluationException e ) |
1095 | |
{ |
1096 | 0 | throw new PluginConfigurationException( goal.getPluginDescriptor(), e.getMessage(), e ); |
1097 | 0 | } |
1098 | |
|
1099 | |
|
1100 | 0 | if ( ( fieldValue == null ) && ( ( value == null ) || ( value.getChildCount() == 0 ) ) ) |
1101 | |
{ |
1102 | 0 | parameter.setExpression( expression ); |
1103 | 0 | invalidParameters.add( parameter ); |
1104 | |
} |
1105 | |
} |
1106 | |
} |
1107 | |
|
1108 | 0 | if ( !invalidParameters.isEmpty() ) |
1109 | |
{ |
1110 | 0 | throw new PluginParameterException( goal, invalidParameters ); |
1111 | |
} |
1112 | 0 | } |
1113 | |
|
1114 | |
private void validatePomConfiguration( MojoDescriptor goal, |
1115 | |
PlexusConfiguration pomConfiguration ) |
1116 | |
throws PluginConfigurationException |
1117 | |
{ |
1118 | 0 | List parameters = goal.getParameters(); |
1119 | |
|
1120 | 0 | if ( parameters == null ) |
1121 | |
{ |
1122 | 0 | return; |
1123 | |
} |
1124 | |
|
1125 | 0 | for ( int i = 0; i < parameters.size(); i++ ) |
1126 | |
{ |
1127 | 0 | Parameter parameter = (Parameter) parameters.get( i ); |
1128 | |
|
1129 | |
|
1130 | 0 | String key = parameter.getName(); |
1131 | |
|
1132 | 0 | PlexusConfiguration value = pomConfiguration.getChild( key, false ); |
1133 | |
|
1134 | 0 | if ( ( value == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) |
1135 | |
{ |
1136 | 0 | key = parameter.getAlias(); |
1137 | 0 | value = pomConfiguration.getChild( key, false ); |
1138 | |
} |
1139 | |
|
1140 | 0 | if ( value != null ) |
1141 | |
{ |
1142 | |
|
1143 | 0 | if ( !parameter.isEditable() ) |
1144 | |
{ |
1145 | 0 | StringBuffer errorMessage = new StringBuffer() |
1146 | |
.append( "ERROR: Cannot override read-only parameter: " ); |
1147 | 0 | errorMessage.append( key ); |
1148 | 0 | errorMessage.append( " in goal: " ).append( goal.getFullGoalName() ); |
1149 | |
|
1150 | 0 | throw new PluginConfigurationException( goal.getPluginDescriptor(), errorMessage.toString() ); |
1151 | |
} |
1152 | |
|
1153 | 0 | String deprecated = parameter.getDeprecated(); |
1154 | 0 | if ( StringUtils.isNotEmpty( deprecated ) ) |
1155 | |
{ |
1156 | 0 | getLogger().warn( "DEPRECATED [" + parameter.getName() + "]: " + deprecated ); |
1157 | |
} |
1158 | |
} |
1159 | |
} |
1160 | 0 | } |
1161 | |
|
1162 | |
private PlexusConfiguration mergeMojoConfiguration( XmlPlexusConfiguration fromPom, |
1163 | |
MojoDescriptor mojoDescriptor ) |
1164 | |
{ |
1165 | 0 | XmlPlexusConfiguration result = new XmlPlexusConfiguration( fromPom.getName() ); |
1166 | 0 | result.setValue( fromPom.getValue( null ) ); |
1167 | |
|
1168 | 0 | if ( mojoDescriptor.getParameters() != null ) |
1169 | |
{ |
1170 | 0 | PlexusConfiguration fromMojo = mojoDescriptor.getMojoConfiguration(); |
1171 | |
|
1172 | 0 | for ( Iterator it = mojoDescriptor.getParameters().iterator(); it.hasNext(); ) |
1173 | |
{ |
1174 | 0 | Parameter parameter = (Parameter) it.next(); |
1175 | |
|
1176 | 0 | String paramName = parameter.getName(); |
1177 | 0 | String alias = parameter.getAlias(); |
1178 | 0 | String implementation = parameter.getImplementation(); |
1179 | |
|
1180 | 0 | PlexusConfiguration pomConfig = fromPom.getChild( paramName ); |
1181 | 0 | PlexusConfiguration aliased = null; |
1182 | |
|
1183 | 0 | if ( alias != null ) |
1184 | |
{ |
1185 | 0 | aliased = fromPom.getChild( alias ); |
1186 | |
} |
1187 | |
|
1188 | 0 | PlexusConfiguration mojoConfig = fromMojo.getChild( paramName, false ); |
1189 | |
|
1190 | |
|
1191 | |
|
1192 | 0 | if ( aliased != null ) |
1193 | |
{ |
1194 | 0 | if ( pomConfig == null ) |
1195 | |
{ |
1196 | 0 | pomConfig = new XmlPlexusConfiguration( paramName ); |
1197 | |
} |
1198 | |
|
1199 | 0 | pomConfig = buildTopDownMergedConfiguration( pomConfig, aliased ); |
1200 | |
} |
1201 | |
|
1202 | 0 | PlexusConfiguration toAdd = null; |
1203 | |
|
1204 | 0 | if ( pomConfig != null ) |
1205 | |
{ |
1206 | 0 | pomConfig = buildTopDownMergedConfiguration( pomConfig, mojoConfig ); |
1207 | |
|
1208 | 0 | if ( StringUtils.isNotEmpty( pomConfig.getValue( null ) ) || ( pomConfig.getChildCount() > 0 ) ) |
1209 | |
{ |
1210 | 0 | toAdd = pomConfig; |
1211 | |
} |
1212 | |
} |
1213 | |
|
1214 | 0 | if ( ( toAdd == null ) && ( mojoConfig != null ) ) |
1215 | |
{ |
1216 | 0 | toAdd = copyConfiguration( mojoConfig ); |
1217 | |
} |
1218 | |
|
1219 | 0 | if ( toAdd != null ) |
1220 | |
{ |
1221 | 0 | if ( ( implementation != null ) && ( toAdd.getAttribute( "implementation", null ) == null ) ) |
1222 | |
{ |
1223 | |
|
1224 | 0 | XmlPlexusConfiguration implementationConf = new XmlPlexusConfiguration( paramName ); |
1225 | |
|
1226 | 0 | implementationConf.setAttribute( "implementation", parameter.getImplementation() ); |
1227 | |
|
1228 | 0 | toAdd = buildTopDownMergedConfiguration( toAdd, implementationConf ); |
1229 | |
} |
1230 | |
|
1231 | 0 | result.addChild( toAdd ); |
1232 | |
} |
1233 | 0 | } |
1234 | |
} |
1235 | 0 | return result; |
1236 | |
} |
1237 | |
|
1238 | |
private XmlPlexusConfiguration buildTopDownMergedConfiguration( PlexusConfiguration dominant, |
1239 | |
PlexusConfiguration recessive ) |
1240 | |
{ |
1241 | 0 | XmlPlexusConfiguration result = new XmlPlexusConfiguration( dominant.getName() ); |
1242 | |
|
1243 | 0 | String value = dominant.getValue( null ); |
1244 | |
|
1245 | 0 | if ( StringUtils.isEmpty( value ) && ( recessive != null ) ) |
1246 | |
{ |
1247 | 0 | value = recessive.getValue( null ); |
1248 | |
} |
1249 | |
|
1250 | 0 | if ( StringUtils.isNotEmpty( value ) ) |
1251 | |
{ |
1252 | 0 | result.setValue( value ); |
1253 | |
} |
1254 | |
|
1255 | 0 | String[] attributeNames = dominant.getAttributeNames(); |
1256 | |
|
1257 | 0 | for ( int i = 0; i < attributeNames.length; i++ ) |
1258 | |
{ |
1259 | 0 | String attributeValue = dominant.getAttribute( attributeNames[i], null ); |
1260 | |
|
1261 | 0 | result.setAttribute( attributeNames[i], attributeValue ); |
1262 | |
} |
1263 | |
|
1264 | 0 | if ( recessive != null ) |
1265 | |
{ |
1266 | 0 | attributeNames = recessive.getAttributeNames(); |
1267 | |
|
1268 | 0 | for ( int i = 0; i < attributeNames.length; i++ ) |
1269 | |
{ |
1270 | 0 | String attributeValue = recessive.getAttribute( attributeNames[i], null ); |
1271 | |
|
1272 | 0 | result.setAttribute( attributeNames[i], attributeValue ); |
1273 | |
} |
1274 | |
} |
1275 | |
|
1276 | 0 | PlexusConfiguration[] children = dominant.getChildren(); |
1277 | |
|
1278 | 0 | for ( int i = 0; i < children.length; i++ ) |
1279 | |
{ |
1280 | 0 | PlexusConfiguration childDom = children[i]; |
1281 | 0 | PlexusConfiguration childRec = recessive == null ? null : recessive.getChild( childDom.getName(), false ); |
1282 | |
|
1283 | 0 | if ( childRec != null ) |
1284 | |
{ |
1285 | 0 | result.addChild( buildTopDownMergedConfiguration( childDom, childRec ) ); |
1286 | |
} |
1287 | |
else |
1288 | |
{ |
1289 | 0 | result.addChild( copyConfiguration( childDom ) ); |
1290 | |
} |
1291 | |
} |
1292 | |
|
1293 | 0 | return result; |
1294 | |
} |
1295 | |
|
1296 | |
public static PlexusConfiguration copyConfiguration( PlexusConfiguration src ) |
1297 | |
{ |
1298 | |
|
1299 | 0 | XmlPlexusConfiguration dom = new XmlPlexusConfiguration( src.getName() ); |
1300 | 0 | dom.setValue( src.getValue( null ) ); |
1301 | |
|
1302 | 0 | String[] attributeNames = src.getAttributeNames(); |
1303 | 0 | for ( int i = 0; i < attributeNames.length; i++ ) |
1304 | |
{ |
1305 | 0 | String attributeName = attributeNames[i]; |
1306 | 0 | dom.setAttribute( attributeName, src.getAttribute( attributeName, null ) ); |
1307 | |
} |
1308 | |
|
1309 | 0 | PlexusConfiguration[] children = src.getChildren(); |
1310 | 0 | for ( int i = 0; i < children.length; i++ ) |
1311 | |
{ |
1312 | 0 | dom.addChild( copyConfiguration( children[i] ) ); |
1313 | |
} |
1314 | |
|
1315 | 0 | return dom; |
1316 | |
} |
1317 | |
|
1318 | |
|
1319 | |
|
1320 | |
|
1321 | |
|
1322 | |
private void populatePluginFields( Mojo plugin, |
1323 | |
MojoDescriptor mojoDescriptor, |
1324 | |
PlexusConfiguration configuration, |
1325 | |
PlexusContainer pluginContainer, |
1326 | |
ExpressionEvaluator expressionEvaluator ) |
1327 | |
throws PluginConfigurationException |
1328 | |
{ |
1329 | 0 | ComponentConfigurator configurator = null; |
1330 | |
|
1331 | |
try |
1332 | |
{ |
1333 | 0 | String configuratorId = mojoDescriptor.getComponentConfigurator(); |
1334 | |
|
1335 | |
|
1336 | |
|
1337 | 0 | if ( StringUtils.isNotEmpty( configuratorId ) ) |
1338 | |
{ |
1339 | 0 | configurator = |
1340 | |
(ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId ); |
1341 | |
} |
1342 | |
else |
1343 | |
{ |
1344 | 0 | configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE ); |
1345 | |
} |
1346 | |
|
1347 | 0 | ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); |
1348 | |
|
1349 | 0 | getLogger().debug( "Configuring mojo '" + mojoDescriptor.getId() + "' -->" ); |
1350 | 0 | configurator.configureComponent( plugin, configuration, expressionEvaluator, |
1351 | |
pluginContainer.getContainerRealm(), listener ); |
1352 | 0 | getLogger().debug( "-- end configuration --" ); |
1353 | |
} |
1354 | 0 | catch ( ComponentConfigurationException e ) |
1355 | |
{ |
1356 | 0 | throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), |
1357 | |
"Unable to parse the created DOM for plugin configuration", e ); |
1358 | |
} |
1359 | 0 | catch ( ComponentLookupException e ) |
1360 | |
{ |
1361 | 0 | throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), |
1362 | |
"Unable to retrieve component configurator for plugin configuration", |
1363 | |
e ); |
1364 | |
} |
1365 | 0 | catch ( NoClassDefFoundError e ) |
1366 | |
{ |
1367 | 0 | throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), |
1368 | |
"A required class was missing during mojo configuration: " + e.getMessage(), e ); |
1369 | |
} |
1370 | 0 | catch ( LinkageError e ) |
1371 | |
{ |
1372 | 0 | if ( getLogger().isFatalErrorEnabled() ) |
1373 | |
{ |
1374 | 0 | getLogger().fatalError( |
1375 | |
configurator.getClass().getName() + "#configureComponent(...) caused a linkage error (" |
1376 | |
+ e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); |
1377 | |
|
1378 | 0 | ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); |
1379 | 0 | StringBuffer sb = new StringBuffer(); |
1380 | 0 | sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); |
1381 | 0 | for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) |
1382 | |
{ |
1383 | 0 | sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); |
1384 | 0 | if ( i != ( pluginRealm.getConstituents().length - 1 ) ) |
1385 | |
{ |
1386 | 0 | sb.append( '\n' ); |
1387 | |
} |
1388 | |
} |
1389 | 0 | getLogger().fatalError( sb.toString() ); |
1390 | |
|
1391 | 0 | ClassRealm containerRealm = container.getContainerRealm(); |
1392 | 0 | sb = new StringBuffer(); |
1393 | 0 | sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); |
1394 | 0 | for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) |
1395 | |
{ |
1396 | 0 | sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); |
1397 | 0 | if ( i != ( containerRealm.getConstituents().length - 1 ) ) |
1398 | |
{ |
1399 | 0 | sb.append( '\n' ); |
1400 | |
} |
1401 | |
} |
1402 | 0 | getLogger().fatalError( sb.toString() ); |
1403 | |
} |
1404 | |
|
1405 | 0 | throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), |
1406 | |
e.getClass().getName() + ": " + e.getMessage(), e ); |
1407 | |
} |
1408 | |
finally |
1409 | |
{ |
1410 | 0 | if ( configurator != null ) |
1411 | |
{ |
1412 | |
try |
1413 | |
{ |
1414 | 0 | pluginContainer.release( configurator ); |
1415 | |
} |
1416 | 0 | catch ( ComponentLifecycleException e ) |
1417 | |
{ |
1418 | 0 | getLogger().debug( "Failed to release plugin container - ignoring." ); |
1419 | 0 | } |
1420 | |
} |
1421 | |
} |
1422 | 0 | } |
1423 | |
|
1424 | |
public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, |
1425 | |
Parameter parameter, |
1426 | |
String expression ) |
1427 | |
{ |
1428 | 0 | StringBuffer message = new StringBuffer(); |
1429 | |
|
1430 | 0 | message.append( "The '" ); |
1431 | 0 | message.append( parameter.getName() ); |
1432 | 0 | message.append( "' parameter is required for the execution of the " ); |
1433 | 0 | message.append( mojo.getFullGoalName() ); |
1434 | 0 | message.append( " mojo and cannot be null." ); |
1435 | 0 | if ( expression != null ) |
1436 | |
{ |
1437 | 0 | message.append( " The retrieval expression was: " ).append( expression ); |
1438 | |
} |
1439 | |
|
1440 | 0 | return message.toString(); |
1441 | |
} |
1442 | |
|
1443 | |
|
1444 | |
|
1445 | |
|
1446 | |
|
1447 | |
public void contextualize( Context context ) |
1448 | |
throws ContextException |
1449 | |
{ |
1450 | 0 | container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); |
1451 | |
|
1452 | 0 | mojoLogger = new DefaultLog( container.getLoggerManager().getLoggerForComponent( Mojo.ROLE ) ); |
1453 | 0 | } |
1454 | |
|
1455 | |
public void initialize() |
1456 | |
{ |
1457 | 0 | artifactFilter = MavenArtifactFilterManager.createStandardFilter(); |
1458 | 0 | } |
1459 | |
|
1460 | |
|
1461 | |
|
1462 | |
|
1463 | |
|
1464 | |
private void resolveTransitiveDependencies( MavenSession context, |
1465 | |
ArtifactResolver artifactResolver, |
1466 | |
String scope, |
1467 | |
ArtifactFactory artifactFactory, |
1468 | |
MavenProject project, boolean isAggregator ) |
1469 | |
throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException |
1470 | |
{ |
1471 | 0 | ArtifactFilter filter = new ScopeArtifactFilter( scope ); |
1472 | |
|
1473 | |
|
1474 | 0 | Artifact artifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(), |
1475 | |
project.getVersion(), project.getPackaging() ); |
1476 | |
|
1477 | |
|
1478 | |
|
1479 | |
|
1480 | 0 | if ( project.getDependencyArtifacts() == null ) |
1481 | |
{ |
1482 | 0 | project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) ); |
1483 | |
} |
1484 | |
else |
1485 | |
{ |
1486 | 0 | project.resolveActiveArtifacts(); |
1487 | |
} |
1488 | |
|
1489 | |
Set resolvedArtifacts; |
1490 | |
try |
1491 | |
{ |
1492 | 0 | ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(), |
1493 | |
artifact, |
1494 | |
project.getManagedVersionMap(), |
1495 | |
context.getLocalRepository(), |
1496 | |
project.getRemoteArtifactRepositories(), |
1497 | |
artifactMetadataSource, filter ); |
1498 | 0 | resolvedArtifacts = result.getArtifacts(); |
1499 | |
} |
1500 | 0 | catch (MultipleArtifactsNotFoundException me) |
1501 | |
{ |
1502 | |
|
1503 | |
|
1504 | |
|
1505 | 0 | if (isAggregator && checkMissingArtifactsInReactor( context.getSortedProjects(), me.getMissingArtifacts() )) |
1506 | |
{ |
1507 | 0 | resolvedArtifacts = new HashSet(me.getResolvedArtifacts()); |
1508 | |
} |
1509 | |
else |
1510 | |
{ |
1511 | |
|
1512 | 0 | throw me; |
1513 | |
} |
1514 | 0 | } |
1515 | 0 | project.setArtifacts( resolvedArtifacts ); |
1516 | 0 | } |
1517 | |
|
1518 | |
|
1519 | |
|
1520 | |
|
1521 | |
|
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
|
1526 | |
|
1527 | |
private boolean checkMissingArtifactsInReactor(Collection projects, Collection missing) |
1528 | |
{ |
1529 | 0 | Collection foundInReactor = new HashSet(); |
1530 | 0 | Iterator iter = missing.iterator(); |
1531 | 0 | while (iter.hasNext()) |
1532 | |
{ |
1533 | 0 | Artifact mArtifact = (Artifact) iter.next(); |
1534 | 0 | Iterator pIter = projects.iterator(); |
1535 | 0 | while (pIter.hasNext()) |
1536 | |
{ |
1537 | 0 | MavenProject p = (MavenProject) pIter.next(); |
1538 | 0 | if (p.getArtifactId().equals( mArtifact.getArtifactId()) && |
1539 | |
p.getGroupId().equals( mArtifact.getGroupId()) && |
1540 | |
p.getVersion().equals( mArtifact.getVersion())) |
1541 | |
{ |
1542 | |
|
1543 | |
|
1544 | |
|
1545 | 0 | getLogger().warn( "The dependency: "+ p.getId()+" can't be resolved but has been found in the reactor.\nThis dependency has been excluded from the plugin execution. You should rerun this mojo after executing mvn install.\n" ); |
1546 | |
|
1547 | |
|
1548 | 0 | foundInReactor.add( p ); |
1549 | 0 | break; |
1550 | |
} |
1551 | 0 | } |
1552 | 0 | } |
1553 | |
|
1554 | |
|
1555 | 0 | return foundInReactor.size() == missing.size(); |
1556 | |
} |
1557 | |
|
1558 | |
|
1559 | |
|
1560 | |
|
1561 | |
|
1562 | |
|
1563 | |
private void downloadDependencies( MavenProject project, |
1564 | |
MavenSession context, |
1565 | |
ArtifactResolver artifactResolver ) |
1566 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
1567 | |
{ |
1568 | 0 | ArtifactRepository localRepository = context.getLocalRepository(); |
1569 | 0 | List remoteArtifactRepositories = project.getRemoteArtifactRepositories(); |
1570 | |
|
1571 | 0 | for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); ) |
1572 | |
{ |
1573 | 0 | Artifact artifact = (Artifact) it.next(); |
1574 | |
|
1575 | 0 | artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository ); |
1576 | 0 | } |
1577 | 0 | } |
1578 | |
|
1579 | |
public Object getPluginComponent( Plugin plugin, |
1580 | |
String role, |
1581 | |
String roleHint ) |
1582 | |
throws PluginManagerException, ComponentLookupException |
1583 | |
{ |
1584 | 0 | PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); |
1585 | |
|
1586 | 0 | PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); |
1587 | |
|
1588 | 0 | return pluginContainer.lookup( role, roleHint ); |
1589 | |
} |
1590 | |
|
1591 | |
public Map getPluginComponents( Plugin plugin, |
1592 | |
String role ) |
1593 | |
throws ComponentLookupException, PluginManagerException |
1594 | |
{ |
1595 | 0 | PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); |
1596 | |
|
1597 | 0 | PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); |
1598 | |
|
1599 | 0 | return pluginContainer.lookupMap( role ); |
1600 | |
} |
1601 | |
} |