mirror of https://github.com/apache/maven.git
[MNG-4162] Removal of all reporting logic from the core of Maven
o Finished converter for reporting section git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@927602 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
38b4606a18
commit
51d640d13b
|
@ -46,6 +46,7 @@ import org.apache.maven.model.normalization.ModelNormalizer;
|
|||
import org.apache.maven.model.path.ModelPathTranslator;
|
||||
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;
|
||||
|
@ -108,6 +109,9 @@ public class DefaultModelBuilder
|
|||
@Requirement
|
||||
private PluginConfigurationExpander pluginConfigurationExpander;
|
||||
|
||||
@Requirement
|
||||
private ReportConfigurationExpander reportConfigurationExpander;
|
||||
|
||||
@Requirement
|
||||
private ReportingConverter reportingConverter;
|
||||
|
||||
|
@ -276,9 +280,11 @@ public class DefaultModelBuilder
|
|||
|
||||
if ( request.isProcessPlugins() )
|
||||
{
|
||||
pluginConfigurationExpander.expandPluginConfiguration( resultModel, request, problems );
|
||||
reportConfigurationExpander.expandPluginConfiguration( resultModel, request, problems );
|
||||
|
||||
reportingConverter.convertReporting( resultModel, request, problems );
|
||||
|
||||
pluginConfigurationExpander.expandPluginConfiguration( resultModel, request, problems );
|
||||
}
|
||||
|
||||
modelValidator.validateEffectiveModel( resultModel, request, problems );
|
||||
|
|
|
@ -26,16 +26,13 @@ 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.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 plugin configuration into individual executions and report sets.
|
||||
* Handles expansion of general build plugin configuration into individual executions.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
|
@ -47,7 +44,6 @@ public class DefaultPluginConfigurationExpander
|
|||
public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
|
||||
{
|
||||
Build build = model.getBuild();
|
||||
Reporting reporting = model.getReporting();
|
||||
|
||||
if ( build != null )
|
||||
{
|
||||
|
@ -60,24 +56,6 @@ public class DefaultPluginConfigurationExpander
|
|||
expand( pluginManagement.getPlugins() );
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void expand( List<Plugin> plugins )
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
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
|
||||
{
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -108,7 +108,7 @@ public class DefaultReportingConverter
|
|||
Xpp3Dom reportPlugin = convert( plugin );
|
||||
reportPlugins.addChild( reportPlugin );
|
||||
|
||||
if ( !reporting.isExcludeDefaults()
|
||||
if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin
|
||||
&& "org.apache.maven.plugins".equals( reportPlugin.getChild( "groupId" ).getValue() )
|
||||
&& "maven-project-info-reports-plugin".equals( reportPlugin.getChild( "artifactId" ).getValue() ) )
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ public class DefaultReportingConverter
|
|||
|
||||
if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin )
|
||||
{
|
||||
Xpp3Dom dom = new Xpp3Dom( "plugin" );
|
||||
Xpp3Dom dom = new Xpp3Dom( "reportPlugin" );
|
||||
|
||||
addDom( dom, "groupId", "org.apache.maven.plugins" );
|
||||
addDom( dom, "artifactId", "maven-project-info-reports-plugin" );
|
||||
|
@ -160,7 +160,7 @@ public class DefaultReportingConverter
|
|||
|
||||
private Xpp3Dom convert( ReportPlugin plugin )
|
||||
{
|
||||
Xpp3Dom dom = new Xpp3Dom( "plugin" );
|
||||
Xpp3Dom dom = new Xpp3Dom( "reportPlugin" );
|
||||
|
||||
addDom( dom, "groupId", plugin.getGroupId() );
|
||||
addDom( dom, "artifactId", plugin.getArtifactId() );
|
||||
|
@ -172,19 +172,42 @@ public class DefaultReportingConverter
|
|||
configuration = new Xpp3Dom( configuration );
|
||||
dom.addChild( configuration );
|
||||
}
|
||||
Xpp3Dom reports = new Xpp3Dom( "reports" );
|
||||
|
||||
if (! plugin.getReportSets().isEmpty())
|
||||
if ( !plugin.getReportSets().isEmpty() )
|
||||
{
|
||||
dom.addChild( reports );
|
||||
Xpp3Dom reportSets = new Xpp3Dom( "reportSets" );
|
||||
for ( ReportSet reportSet : plugin.getReportSets() )
|
||||
{
|
||||
Xpp3Dom rs = convert( reportSet );
|
||||
reportSets.addChild( rs );
|
||||
}
|
||||
dom.addChild( reportSets );
|
||||
}
|
||||
// TODO: Clarifiy conversion f reporset.configuration
|
||||
for ( ReportSet reportSet : plugin.getReportSets() )
|
||||
|
||||
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 )
|
||||
{
|
||||
for (String report : reportSet.getReports())
|
||||
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;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.maven.model.building.ModelBuildingRequest;
|
|||
import org.apache.maven.model.building.ModelProblemCollector;
|
||||
|
||||
/**
|
||||
* Handles expansion of general plugin configuration into individual executions and report sets.
|
||||
* Handles expansion of general build plugin configuration into individual executions.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
|
@ -32,10 +32,9 @@ public interface PluginConfigurationExpander
|
|||
{
|
||||
|
||||
/**
|
||||
* Merges values from general plugin configuration into the individual plugin executions and reports sets of the
|
||||
* given model.
|
||||
* Merges values from general build plugin configuration into the individual plugin executions of the given model.
|
||||
*
|
||||
* @param model The model whose plugin configuration should be expanded, must not be <code>null</code>.
|
||||
* @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}.
|
||||
*/
|
||||
|
|
|
@ -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 );
|
||||
|
||||
}
|
Loading…
Reference in New Issue