1 package org.apache.maven.plugins.plugin.descriptor;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
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.codehaus.plexus.configuration.PlexusConfiguration;
27 import org.codehaus.plexus.configuration.PlexusConfigurationException;
28
29 /**
30 * Reads the plugin descriptor and adds the fix for MNG-6109 when using Maven-3.3.9 and before.
31 * Class can be removed once Maven 3.5.0 is the prerequisite for this plugin.
32 *
33 * @author Robert Scholte
34 * @since 3.5.1
35 */
36 public class MNG6109PluginDescriptorBuilder extends PluginDescriptorBuilder
37 {
38
39 @Override
40 public MojoDescriptor buildComponentDescriptor( PlexusConfiguration c, PluginDescriptor pluginDescriptor )
41 throws PlexusConfigurationException
42 {
43 MojoDescriptor mojoDescriptor = super.buildComponentDescriptor( c, pluginDescriptor );
44
45 // ----------------------------------------------------------------------
46 // Parameters
47 // ----------------------------------------------------------------------
48
49 PlexusConfiguration[] parameterConfigurations = c.getChild( "parameters" ).getChildren( "parameter" );
50
51 for ( PlexusConfiguration d : parameterConfigurations )
52 {
53 String parameterName = d.getChild( "name" ).getValue();
54 Parameter pd = (Parameter) mojoDescriptor.getParameterMap().get( parameterName );
55
56 String parameterSince = d.getChild( "since" ).getValue();
57 pd.setSince( parameterSince );
58 }
59
60 return mojoDescriptor;
61 }
62 }