From 1968951a53cfefb75324f735579cbb68879ad5e0 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 9 Jan 2023 16:06:48 +0100 Subject: [PATCH] [MNG-7642] Restore compatibility with flatten-maven-plugin (#947) Revert "[MNG-7505] Remove ReportingConverter (#906)" This reverts commit adf89ef63ffca07e490f5cc550f9411bad1a7bd6. --- .../model/building/DefaultModelBuilder.java | 10 +++++ .../building/DefaultModelBuilderFactory.java | 12 ++++++ .../plugin/DefaultReportingConverter.java | 42 ++++++++++++++++++ .../model/plugin/ReportingConverter.java | 43 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java create mode 100644 maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java 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 2b3b5f102a..d4c8cbde05 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 @@ -76,6 +76,7 @@ import org.apache.maven.model.path.ProfileActivationFilePathInterpolator; 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; @@ -625,6 +626,15 @@ public class DefaultModelBuilder implements ModelBuilder { versionProcessor); } + /** + * @deprecated since Maven 4 + * @see DefaultModelBuilderFactory#setReportingConverter(ReportingConverter) + */ + @Deprecated + public DefaultModelBuilder setReportingConverter(ReportingConverter reportingConverter) { + return this; + } + @Override public DefaultTransformerContextBuilder newTransformerContextBuilder() { return new DefaultTransformerContextBuilder(); 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 bf573541a0..3ddecdc570 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 @@ -50,9 +50,11 @@ import org.apache.maven.model.path.ProfileActivationFilePathInterpolator; 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; @@ -183,6 +185,11 @@ public class DefaultModelBuilderFactory { return this; } + @Deprecated + public DefaultModelBuilderFactory setReportingConverter(ReportingConverter reportingConverter) { + return this; + } + public DefaultModelBuilderFactory setProfileActivationFilePathInterpolator( ProfileActivationFilePathInterpolator profileActivationFilePathInterpolator) { this.profileActivationFilePathInterpolator = profileActivationFilePathInterpolator; @@ -294,6 +301,11 @@ public class DefaultModelBuilderFactory { return new DefaultReportConfigurationExpander(); } + @Deprecated + protected ReportingConverter newReportingConverter() { + return new DefaultReportingConverter(); + } + private ModelSourceTransformer newModelSourceTransformer() { return new DefaultModelSourceTransformer(); } 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 new file mode 100644 index 0000000000..69f767ec9a --- /dev/null +++ b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java @@ -0,0 +1,42 @@ +/* + * 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.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 + * @deprecated since maven 4.0, this class is now a no-op class and is only here for compatibility + */ +@Named +@Singleton +@Deprecated +public class DefaultReportingConverter implements ReportingConverter { + + @Override + public void convertReporting(Model model, ModelBuildingRequest request, ModelProblemCollector problems) {} +} 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 new file mode 100644 index 0000000000..bffde5c00b --- /dev/null +++ b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java @@ -0,0 +1,43 @@ +/* + * 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 + * @deprecated since maven 4.0, this interface is not used anymore and is only here for compatibility + */ +@Deprecated +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); +}