diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin')
7 files changed, 563 insertions, 0 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java new file mode 100644 index 00000000..dc7cf13b --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultPluginConfigurationExpander.java @@ -0,0 +1,83 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * Handles expansion of general build plugin configuration into individual executions. + * + * @author Benjamin Bentmann + */ +@Component( role = PluginConfigurationExpander.class ) +public class DefaultPluginConfigurationExpander + implements PluginConfigurationExpander +{ + + @Override + public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Build build = model.getBuild(); + + if ( build != null ) + { + expand( build.getPlugins() ); + + PluginManagement pluginManagement = build.getPluginManagement(); + + if ( pluginManagement != null ) + { + expand( pluginManagement.getPlugins() ); + } + } + } + + private void expand( List<Plugin> plugins ) + { + for ( Plugin plugin : plugins ) + { + Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration(); + + if ( pluginConfiguration != null ) + { + for ( PluginExecution execution : plugin.getExecutions() ) + { + Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration(); + + executionConfiguration = + Xpp3Dom.mergeXpp3Dom( executionConfiguration, new Xpp3Dom( pluginConfiguration ) ); + + execution.setConfiguration( executionConfiguration ); + } + } + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.java new file mode 100644 index 00000000..9c842994 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportConfigurationExpander.java @@ -0,0 +1,65 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * Handles expansion of general report plugin configuration into individual report sets. + * + * @author Benjamin Bentmann + */ +@Component( role = ReportConfigurationExpander.class ) +public class DefaultReportConfigurationExpander + implements ReportConfigurationExpander +{ + + @Override + public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Reporting reporting = model.getReporting(); + + if ( reporting != null ) + { + for ( ReportPlugin reportPlugin : reporting.getPlugins() ) + { + Xpp3Dom parentDom = (Xpp3Dom) reportPlugin.getConfiguration(); + + if ( parentDom != null ) + { + for ( ReportSet execution : reportPlugin.getReportSets() ) + { + Xpp3Dom childDom = (Xpp3Dom) execution.getConfiguration(); + childDom = Xpp3Dom.mergeXpp3Dom( childDom, new Xpp3Dom( parentDom ) ); + execution.setConfiguration( childDom ); + } + } + } + } + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java new file mode 100644 index 00000000..d918d9e8 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java @@ -0,0 +1,240 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * Handles conversion of the legacy reporting section into the configuration of the new Maven Site Plugin. + * + * @author Benjamin Bentmann + */ +@Component( role = ReportingConverter.class ) +public class DefaultReportingConverter + implements ReportingConverter +{ + + @Override + public void convertReporting( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) + { + Reporting reporting = model.getReporting(); + + if ( reporting == null ) + { + return; + } + + Build build = model.getBuild(); + + if ( build == null ) + { + build = new Build(); + model.setBuild( build ); + } + + Plugin sitePlugin = findSitePlugin( build ); + + if ( sitePlugin == null ) + { + sitePlugin = new Plugin(); + sitePlugin.setArtifactId( "maven-site-plugin" ); + PluginManagement pluginManagement = build.getPluginManagement(); + if ( pluginManagement == null ) + { + pluginManagement = new PluginManagement(); + build.setPluginManagement( pluginManagement ); + } + pluginManagement.addPlugin( sitePlugin ); + } + + Xpp3Dom configuration = (Xpp3Dom) sitePlugin.getConfiguration(); + + if ( configuration == null ) + { + configuration = new Xpp3Dom( "configuration" ); + sitePlugin.setConfiguration( configuration ); + } + + Xpp3Dom reportPlugins = configuration.getChild( "reportPlugins" ); + + if ( reportPlugins != null ) + { + // new-style report configuration already present, assume user handled entire conversion + return; + } + + if ( configuration.getChild( "outputDirectory" ) == null ) + { + addDom( configuration, "outputDirectory", reporting.getOutputDirectory() ); + } + + reportPlugins = new Xpp3Dom( "reportPlugins" ); + configuration.addChild( reportPlugins ); + + boolean hasMavenProjectInfoReportsPlugin = false; + + /* waiting for MSITE-484 before deprecating <reporting> section + if ( !reporting.getPlugins().isEmpty() + && request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ) + { + + problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31 ) + .setMessage( "The <reporting> section is deprecated, please move the reports to the <configuration>" + + " section of the new Maven Site Plugin." ) + .setLocation( reporting.getLocation( "" ) ) ); + }*/ + + for ( ReportPlugin plugin : reporting.getPlugins() ) + { + Xpp3Dom reportPlugin = convert( plugin ); + reportPlugins.addChild( reportPlugin ); + + if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin + && "org.apache.maven.plugins".equals( plugin.getGroupId() ) + && "maven-project-info-reports-plugin".equals( plugin.getArtifactId() ) ) + { + hasMavenProjectInfoReportsPlugin = true; + } + } + + if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin ) + { + Xpp3Dom dom = new Xpp3Dom( "reportPlugin" ); + + addDom( dom, "groupId", "org.apache.maven.plugins" ); + addDom( dom, "artifactId", "maven-project-info-reports-plugin" ); + + reportPlugins.addChild( dom ); + } + } + + private Plugin findSitePlugin( Build build ) + { + for ( Plugin plugin : build.getPlugins() ) + { + if ( isSitePlugin( plugin ) ) + { + return plugin; + } + } + + PluginManagement pluginManagement = build.getPluginManagement(); + if ( pluginManagement != null ) + { + for ( Plugin plugin : pluginManagement.getPlugins() ) + { + if ( isSitePlugin( plugin ) ) + { + return plugin; + } + } + } + + return null; + } + + private boolean isSitePlugin( Plugin plugin ) + { + return "maven-site-plugin".equals( plugin.getArtifactId() ) + && "org.apache.maven.plugins".equals( plugin.getGroupId() ); + } + + private Xpp3Dom convert( ReportPlugin plugin ) + { + Xpp3Dom dom = new Xpp3Dom( "reportPlugin" ); + + addDom( dom, "groupId", plugin.getGroupId() ); + addDom( dom, "artifactId", plugin.getArtifactId() ); + addDom( dom, "version", plugin.getVersion() ); + + Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); + if ( configuration != null ) + { + configuration = new Xpp3Dom( configuration ); + dom.addChild( configuration ); + } + + if ( !plugin.getReportSets().isEmpty() ) + { + Xpp3Dom reportSets = new Xpp3Dom( "reportSets" ); + for ( ReportSet reportSet : plugin.getReportSets() ) + { + Xpp3Dom rs = convert( reportSet ); + reportSets.addChild( rs ); + } + dom.addChild( reportSets ); + } + + return dom; + } + + private Xpp3Dom convert( ReportSet reportSet ) + { + Xpp3Dom dom = new Xpp3Dom( "reportSet" ); + + addDom( dom, "id", reportSet.getId() ); + + Xpp3Dom configuration = (Xpp3Dom) reportSet.getConfiguration(); + if ( configuration != null ) + { + configuration = new Xpp3Dom( configuration ); + dom.addChild( configuration ); + } + + if ( !reportSet.getReports().isEmpty() ) + { + Xpp3Dom reports = new Xpp3Dom( "reports" ); + for ( String report : reportSet.getReports() ) + { + addDom( reports, "report", report ); + } + dom.addChild( reports ); + } + + return dom; + } + + private void addDom( Xpp3Dom parent, String childName, String childValue ) + { + if ( StringUtils.isNotEmpty( childValue ) ) + { + parent.addChild( newDom( childName, childValue ) ); + } + } + + private Xpp3Dom newDom( String name, String value ) + { + Xpp3Dom dom = new Xpp3Dom( name ); + dom.setValue( value ); + return dom; + } + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/LifecycleBindingsInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/LifecycleBindingsInjector.java new file mode 100644 index 00000000..9c0f06de --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/LifecycleBindingsInjector.java @@ -0,0 +1,46 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles injection of plugin executions induced by the lifecycle bindings for a packaging. + * + * @author Benjamin Bentmann + */ +public interface LifecycleBindingsInjector +{ + + /** + * Injects plugin executions induced by lifecycle bindings into the specified model. The model has already undergone + * injection of plugin management so any plugins that are injected by lifecycle bindings and are not already present + * in the model's plugin section need to be subjected to the model's plugin management. + * + * @param model The model into which to inject the default plugin executions for its packaging, must not be + * <code>null</code>. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/PluginConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/PluginConfigurationExpander.java new file mode 100644 index 00000000..23994aa6 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/PluginConfigurationExpander.java @@ -0,0 +1,43 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles expansion of general build plugin configuration into individual executions. + * + * @author Benjamin Bentmann + */ +public interface PluginConfigurationExpander +{ + + /** + * Merges values from general build plugin configuration into the individual plugin executions of the given model. + * + * @param model The model whose build plugin configuration should be expanded, must not be <code>null</code>. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportConfigurationExpander.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportConfigurationExpander.java new file mode 100644 index 00000000..28ad5962 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportConfigurationExpander.java @@ -0,0 +1,43 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles expansion of general report plugin configuration into individual report sets. + * + * @author Benjamin Bentmann + */ +public interface ReportConfigurationExpander +{ + + /** + * Merges values from general report plugin configuration into the individual reports sets of the given model. + * + * @param model The model whose report plugin configuration should be expanded, must not be <code>null</code>. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java new file mode 100644 index 00000000..c5ea338c --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java @@ -0,0 +1,43 @@ +package org.apache.maven.model.plugin; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Model; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; + +/** + * Handles conversion of the legacy reporting section into the configuration of the new Maven Site Plugin. + * + * @author Benjamin Bentmann + */ +public interface ReportingConverter +{ + + /** + * Converts values from model's reporting section into the configuration for the new Maven Site Plugin. + * + * @param model The model whose reporting section should be converted, must not be <code>null</code>. + * @param request The model building request that holds further settings, must not be {@code null}. + * @param problems The container used to collect problems that were encountered, must not be {@code null}. + */ + void convertReporting( Model model, ModelBuildingRequest request, ModelProblemCollector problems ); + +} |