diff --git a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java index 0de6e361b881..e456b057bec7 100644 --- a/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -1371,7 +1371,7 @@ public void testPluginInheritanceSimple() throws Exception { @Test public void testPluginManagementDuplicate() throws Exception { PomTestWrapper pom = this.buildPom("plugin-management-duplicate/sub"); - assertEquals(8, ((List) pom.getValue("build/pluginManagement/plugins")).size()); + assertEquals(7, ((List) pom.getValue("build/pluginManagement/plugins")).size()); } @Test diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 3fba160ceead..87386331a6f6 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -77,7 +77,6 @@ import org.apache.maven.model.plugin.LifecycleBindingsInjector; import org.apache.maven.model.plugin.PluginConfigurationExpander; import org.apache.maven.model.plugin.ReportConfigurationExpander; -import org.apache.maven.model.plugin.ReportingConverter; import org.apache.maven.model.profile.DefaultProfileActivationContext; import org.apache.maven.model.profile.ProfileActivationContext; import org.apache.maven.model.profile.ProfileInjector; @@ -118,7 +117,6 @@ public class DefaultModelBuilder implements ModelBuilder { private final LifecycleBindingsInjector lifecycleBindingsInjector; private final PluginConfigurationExpander pluginConfigurationExpander; private final ReportConfigurationExpander reportConfigurationExpander; - private final ReportingConverter reportingConverter; private final ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator; private final ModelVersionProcessor versionProcessor; @@ -141,7 +139,6 @@ public DefaultModelBuilder( @Nullable LifecycleBindingsInjector lifecycleBindingsInjector, PluginConfigurationExpander pluginConfigurationExpander, ReportConfigurationExpander reportConfigurationExpander, - ReportingConverter reportingConverter, ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator, ModelVersionProcessor versionProcessor) { this.modelProcessor = modelProcessor; @@ -160,7 +157,6 @@ public DefaultModelBuilder( this.lifecycleBindingsInjector = lifecycleBindingsInjector; this.pluginConfigurationExpander = pluginConfigurationExpander; this.reportConfigurationExpander = reportConfigurationExpander; - this.reportingConverter = reportingConverter; this.profileActivationFilePathInterpolator = profileActivationFilePathInterpolator; this.versionProcessor = versionProcessor; } @@ -188,7 +184,6 @@ public DefaultModelBuilder setModelProcessor(ModelProcessor modelProcessor) { lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -216,7 +211,6 @@ public DefaultModelBuilder setModelValidator(ModelValidator modelValidator) { lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -244,7 +238,6 @@ public DefaultModelBuilder setModelNormalizer(ModelNormalizer modelNormalizer) { lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -272,7 +265,6 @@ public DefaultModelBuilder setModelInterpolator(ModelInterpolator modelInterpola lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -300,7 +292,6 @@ public DefaultModelBuilder setModelPathTranslator(ModelPathTranslator modelPathT lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -328,7 +319,6 @@ public DefaultModelBuilder setModelUrlNormalizer(ModelUrlNormalizer modelUrlNorm lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -356,7 +346,6 @@ public DefaultModelBuilder setSuperPomProvider(SuperPomProvider superPomProvider lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -384,7 +373,6 @@ public DefaultModelBuilder setInheritanceAssembler(InheritanceAssembler inherita lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -412,7 +400,6 @@ public DefaultModelBuilder setProfileSelector(ProfileSelector profileSelector) { lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -440,7 +427,6 @@ public DefaultModelBuilder setProfileInjector(ProfileInjector profileInjector) { lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -468,7 +454,6 @@ public DefaultModelBuilder setPluginManagementInjector(PluginManagementInjector lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -497,7 +482,6 @@ public DefaultModelBuilder setDependencyManagementInjector( lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -526,7 +510,6 @@ public DefaultModelBuilder setDependencyManagementImporter( lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -554,7 +537,6 @@ public DefaultModelBuilder setLifecycleBindingsInjector(LifecycleBindingsInjecto lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -582,7 +564,6 @@ public DefaultModelBuilder setPluginConfigurationExpander(PluginConfigurationExp lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -610,35 +591,6 @@ public DefaultModelBuilder setReportConfigurationExpander(ReportConfigurationExp lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, - profileActivationFilePathInterpolator, - versionProcessor); - } - - /** - * @deprecated since Maven 4 - * @see DefaultModelBuilderFactory#setReportingConverter(ReportingConverter) - */ - @Deprecated - public DefaultModelBuilder setReportingConverter(ReportingConverter reportingConverter) { - return new DefaultModelBuilder( - modelProcessor, - modelValidator, - modelNormalizer, - modelInterpolator, - modelPathTranslator, - modelUrlNormalizer, - superPomProvider, - inheritanceAssembler, - profileSelector, - profileInjector, - pluginManagementInjector, - dependencyManagementInjector, - dependencyManagementImporter, - lifecycleBindingsInjector, - pluginConfigurationExpander, - reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -667,7 +619,6 @@ public DefaultModelBuilder setProfileActivationFilePathInterpolator( lifecycleBindingsInjector, pluginConfigurationExpander, reportConfigurationExpander, - reportingConverter, profileActivationFilePathInterpolator, versionProcessor); } @@ -963,9 +914,6 @@ private ModelBuildingResult build( // reports configuration reportConfigurationExpander.expandPluginConfiguration(resultModel, request, problems); - // reports conversion to decoupled site plugin - reportingConverter.convertReporting(resultModel, request, problems); - // plugins configuration pluginConfigurationExpander.expandPluginConfiguration(resultModel, request, problems); } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java index fcb428119a4f..2f571d190fbd 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilderFactory.java @@ -49,11 +49,9 @@ import org.apache.maven.model.path.UrlNormalizer; import org.apache.maven.model.plugin.DefaultPluginConfigurationExpander; import org.apache.maven.model.plugin.DefaultReportConfigurationExpander; -import org.apache.maven.model.plugin.DefaultReportingConverter; import org.apache.maven.model.plugin.LifecycleBindingsInjector; import org.apache.maven.model.plugin.PluginConfigurationExpander; import org.apache.maven.model.plugin.ReportConfigurationExpander; -import org.apache.maven.model.plugin.ReportingConverter; import org.apache.maven.model.profile.DefaultProfileInjector; import org.apache.maven.model.profile.DefaultProfileSelector; import org.apache.maven.model.profile.ProfileInjector; @@ -96,7 +94,6 @@ public class DefaultModelBuilderFactory { private LifecycleBindingsInjector lifecycleBindingsInjector; private PluginConfigurationExpander pluginConfigurationExpander; private ReportConfigurationExpander reportConfigurationExpander; - private ReportingConverter reportingConverter; private ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator; private ModelVersionProcessor versionProcessor; @@ -185,11 +182,6 @@ public DefaultModelBuilderFactory setReportConfigurationExpander( return this; } - public DefaultModelBuilderFactory setReportingConverter(ReportingConverter reportingConverter) { - this.reportingConverter = reportingConverter; - return this; - } - public DefaultModelBuilderFactory setProfileActivationFilePathInterpolator( ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator) { this.profileActivationFilePathInterpolator = profileActivationFilePathInterpolator; @@ -301,10 +293,6 @@ protected ReportConfigurationExpander newReportConfigurationExpander() { return new DefaultReportConfigurationExpander(); } - protected ReportingConverter newReportingConverter() { - return new DefaultReportingConverter(); - } - private ModelSourceTransformer newModelSourceTransformer() { return new DefaultModelSourceTransformer(); } @@ -332,7 +320,6 @@ public DefaultModelBuilder newInstance() { lifecycleBindingsInjector != null ? lifecycleBindingsInjector : newLifecycleBindingsInjector(), pluginConfigurationExpander != null ? pluginConfigurationExpander : newPluginConfigurationExpander(), reportConfigurationExpander != null ? reportConfigurationExpander : newReportConfigurationExpander(), - reportingConverter != null ? reportingConverter : newReportingConverter(), profileActivationFilePathInterpolator != null ? profileActivationFilePathInterpolator : newProfileActivationFilePathInterpolator(), diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java deleted file mode 100644 index 519253afe5c1..000000000000 --- a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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. - */ -package org.apache.maven.model.plugin; - -import javax.inject.Named; -import javax.inject.Singleton; -import org.apache.maven.model.Build; -import org.apache.maven.model.InputLocation; -import org.apache.maven.model.InputSource; -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.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblem.Version; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.Xpp3Dom; - -/** - * Handles conversion of the <reporting> section into the configuration of Maven Site Plugin 3.x, - * i.e. reportPlugins and outputDirectory parameters. - * - * @author Benjamin Bentmann - */ -@Named -@Singleton -public class DefaultReportingConverter implements ReportingConverter { - private final InputLocation location; - - { - String modelId = "org.apache.maven:maven-model-builder:" - + this.getClass().getPackage().getImplementationVersion() + ":reporting-converter"; - InputSource inputSource = new InputSource(); - inputSource.setModelId(modelId); - location = new InputLocation(-1, -1, inputSource); - location.setLocation(0, location); - } - - @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); - model.setLocation("build", location); - } - - Plugin sitePlugin = findSitePlugin(build); - - if (sitePlugin == null) { - sitePlugin = new Plugin(); - sitePlugin.setArtifactId("maven-site-plugin"); - sitePlugin.setLocation("artifactId", location); - 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", location); - sitePlugin.setConfiguration(configuration); - } - - Xpp3Dom reportPlugins = configuration.getChild("reportPlugins"); - - if (reportPlugins != null) { - // new-style report configuration already present: warn since this new style has been deprecated - // in favor of classical reporting section MSITE-647 / MSITE-684 - problems.add(new ModelProblemCollectorRequest(Severity.WARNING, Version.BASE) - .setMessage("Reporting configuration should be done in section, " - + "not in maven-site-plugin as reportPlugins parameter.") - .setLocation(sitePlugin.getLocation("configuration"))); - return; - } - - if (configuration.getChild("outputDirectory") == null) { - addDom( - configuration, - "outputDirectory", - reporting.getOutputDirectory(), - reporting.getLocation("outputDirectory")); - } - - reportPlugins = new Xpp3Dom("reportPlugins", location); - configuration.addChild(reportPlugins); - - boolean hasMavenProjectInfoReportsPlugin = false; - - /* waiting for MSITE-484 before deprecating section - if ( !reporting.getPlugins().isEmpty() - && request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 ) - { - - problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31 ) - .setMessage( "The section is deprecated, please move the reports to the " - + " 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", location); - - 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", plugin.getLocation("")); - - addDom(dom, "groupId", plugin.getGroupId(), plugin.getLocation("groupId")); - addDom(dom, "artifactId", plugin.getArtifactId(), plugin.getLocation("artifactId")); - addDom(dom, "version", plugin.getVersion(), plugin.getLocation("version")); - - Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); - if (configuration != null) { - configuration = new Xpp3Dom(configuration); - dom.addChild(configuration); - } - - if (!plugin.getReportSets().isEmpty()) { - Xpp3Dom reportSets = new Xpp3Dom("reportSets", plugin.getLocation("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", reportSet.getLocation("")); - - InputLocation idLocation = reportSet.getLocation("id"); - addDom(dom, "id", reportSet.getId(), idLocation == null ? location : idLocation); - - Xpp3Dom configuration = (Xpp3Dom) reportSet.getConfiguration(); - if (configuration != null) { - configuration = new Xpp3Dom(configuration); - dom.addChild(configuration); - } - - if (!reportSet.getReports().isEmpty()) { - InputLocation location = reportSet.getLocation("reports"); - Xpp3Dom reports = new Xpp3Dom("reports", location); - int n = 0; - for (String report : reportSet.getReports()) { - addDom(reports, "report", report, (location == null) ? null : location.getLocation(n++)); - } - dom.addChild(reports); - } - - return dom; - } - - private void addDom(Xpp3Dom parent, String childName, String childValue) { - addDom(parent, childName, childValue, location); - } - - private void addDom(Xpp3Dom parent, String childName, String childValue, InputLocation location) { - if (StringUtils.isNotEmpty(childValue)) { - parent.addChild(newDom(childName, childValue, location)); - } - } - - private Xpp3Dom newDom(String name, String value, InputLocation location) { - Xpp3Dom dom = new Xpp3Dom(name, location); - dom.setValue(value); - return dom; - } -} diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java deleted file mode 100644 index 6e74a0cc3992..000000000000 --- a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ -package org.apache.maven.model.plugin; - -import org.apache.maven.model.Model; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblemCollector; - -/** - * Handles conversion of the <reporting> section into the configuration of Maven Site Plugin 3.x, - * i.e. reportPlugins and outputDirectory parameters. - * - * @author Benjamin Bentmann - */ -public interface ReportingConverter { - - /** - * Converts values from model's reporting section into the configuration for Maven Site Plugin 3.x. - * - * @param model The model whose reporting section should be converted, must not be null. - * @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); -}