1 package org.apache.maven.plugins.plugin.descriptor;
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.plugin.descriptor.MojoDescriptor;
23 import org.apache.maven.plugin.descriptor.Parameter;
24 import org.apache.maven.plugin.descriptor.PluginDescriptor;
25 import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
26 import org.apache.maven.rtinfo.RuntimeInformation;
27 import org.apache.maven.tools.plugin.EnhancedParameterWrapper;
28 import org.codehaus.plexus.configuration.PlexusConfiguration;
29 import org.codehaus.plexus.configuration.PlexusConfigurationException;
30 import org.apache.maven.plugin.plugin.report.PluginReport;
31
32 import java.net.URI;
33
34
35
36
37
38
39
40 public class EnhancedPluginDescriptorBuilder extends PluginDescriptorBuilder
41 {
42 private final boolean requireAddingMissingParameterSinceField;
43
44 public EnhancedPluginDescriptorBuilder( RuntimeInformation rtInfo )
45 {
46 this( rtInfo.isMavenVersion( "[,3.3.9]" ) );
47 }
48
49 EnhancedPluginDescriptorBuilder( boolean requireAddingMissingParameterSinceField )
50 {
51 this.requireAddingMissingParameterSinceField = requireAddingMissingParameterSinceField;
52 }
53
54 @Override
55 public MojoDescriptor buildComponentDescriptor( PlexusConfiguration c, PluginDescriptor pluginDescriptor )
56 throws PlexusConfigurationException
57 {
58 MojoDescriptor mojoDescriptor = super.buildComponentDescriptor( c, pluginDescriptor );
59
60
61
62
63
64 PlexusConfiguration[] parameterConfigurations = c.getChild( "parameters" ).getChildren( "parameter" );
65
66 for ( PlexusConfiguration d : parameterConfigurations )
67 {
68 String parameterName = d.getChild( "name" ).getValue();
69
70 Parameter pd = mojoDescriptor.getParameterMap().get( parameterName );
71 if ( requireAddingMissingParameterSinceField )
72 {
73 addMissingParameterSinceField( pd, d );
74 }
75 PlexusConfiguration configTypeJavadocUrl = d.getChild( "typeJavadocUrl", false );
76 if ( configTypeJavadocUrl != null )
77 {
78 String parameterTypeJavadocUrl = configTypeJavadocUrl.getValue();
79 EnhancedParameterWrapper enhancedParameter = new EnhancedParameterWrapper( pd );
80 enhancedParameter.setTypeJavadocUrl( URI.create( parameterTypeJavadocUrl ) );
81 mojoDescriptor.getParameters().set( mojoDescriptor.getParameters().indexOf( pd ), enhancedParameter );
82 mojoDescriptor.getParameterMap().put( parameterName, enhancedParameter );
83 }
84 }
85 return mojoDescriptor;
86 }
87
88
89
90
91
92
93
94
95
96
97
98 void addMissingParameterSinceField( Parameter pd, PlexusConfiguration d ) throws PlexusConfigurationException
99 {
100 String parameterSince = d.getChild( "since" ).getValue();
101 pd.setSince( parameterSince );
102 }
103 }