The stuff is recorded/documented here [1].
Comment are welcome.

Thanks,
--
Olivier

[1] 
http://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+and+site+plugin#Maven3.xandsiteplugin-Configurationformat.

2009/9/29 Olivier Lamy <ol...@apache.org>:
> thanks benjamin :-)
>
> 2009/9/29  <bentm...@apache.org>:
>> Author: bentmann
>> Date: Tue Sep 29 14:51:28 2009
>> New Revision: 819974
>>
>> URL: http://svn.apache.org/viewvc?rev=819974&view=rev
>> Log:
>> [MNG-4162] Removal of all reporting logic from the core of Maven
>>
>> o Started converter to populate new site plugin configuration from legacy 
>> reporting section
>>
>> Added:
>>    
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java
>>    (with props)
>>    
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java
>>    (with props)
>> Modified:
>>    
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
>>
>> Modified: 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
>> URL: 
>> http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java?rev=819974&r1=819973&r2=819974&view=diff
>> ==============================================================================
>> --- 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
>>  (original)
>> +++ 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
>>  Tue Sep 29 14:51:28 2009
>> @@ -46,6 +46,7 @@
>>  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.ReportingConverter;
>>  import org.apache.maven.model.profile.DefaultProfileActivationContext;
>>  import org.apache.maven.model.profile.ProfileActivationContext;
>>  import org.apache.maven.model.profile.ProfileInjector;
>> @@ -108,6 +109,9 @@
>>     @Requirement
>>     private PluginConfigurationExpander pluginConfigurationExpander;
>>
>> +   �...@requirement
>> +    private ReportingConverter reportingConverter;
>> +
>>     public ModelBuildingResult build( ModelBuildingRequest request )
>>         throws ModelBuildingException
>>     {
>> @@ -254,6 +258,8 @@
>>         if ( request.isProcessPlugins() )
>>         {
>>             pluginConfigurationExpander.expandPluginConfiguration( 
>> resultModel, request, problems );
>> +
>> +            reportingConverter.convertReporting( resultModel, request, 
>> problems );
>>         }
>>
>>         modelValidator.validateEffectiveModel( resultModel, request, 
>> problems );
>>
>> Added: 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java
>> URL: 
>> http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java?rev=819974&view=auto
>> ==============================================================================
>> --- 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java
>>  (added)
>> +++ 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java
>>  Tue Sep 29 14:51:28 2009
>> @@ -0,0 +1,193 @@
>> +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
>> +{
>> +
>> +    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" );
>> +            build.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;
>> +        }
>> +
>> +        problems.addWarning( "The <reporting> section is deprecated"
>> +            + ", please move the reports to the <configuration> section of 
>> the new Maven Site Plugin." );
>> +
>> +        if ( configuration.getChild( "outputDirectory" ) == null )
>> +        {
>> +            addDom( configuration, "outputDirectory", 
>> reporting.getOutputDirectory() );
>> +        }
>> +
>> +        reportPlugins = new Xpp3Dom( "reportPlugins" );
>> +        configuration.addChild( reportPlugins );
>> +
>> +        boolean hasMavenProjectInfoReportsPlugin = false;
>> +
>> +        for ( ReportPlugin plugin : reporting.getPlugins() )
>> +        {
>> +            Xpp3Dom reportPlugin = convert( plugin );
>> +            reportPlugins.addChild( reportPlugin );
>> +
>> +            if ( !reporting.isExcludeDefaults()
>> +                && "org.apache.maven.plugins".equals( 
>> reportPlugin.getChild( "groupId" ).getValue() )
>> +                && "maven-project-info-reports-plugin".equals( 
>> reportPlugin.getChild( "artifactId" ).getValue() ) )
>> +            {
>> +                hasMavenProjectInfoReportsPlugin = true;
>> +            }
>> +        }
>> +
>> +        if ( !reporting.isExcludeDefaults() && 
>> !hasMavenProjectInfoReportsPlugin )
>> +        {
>> +            Xpp3Dom dom = new Xpp3Dom( "plugin" );
>> +
>> +            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( "plugin" );
>> +
>> +        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 );
>> +        }
>> +
>> +        // TODO: Clarifiy conversion
>> +        for ( ReportSet reportSet : plugin.getReportSets() )
>> +        {
>> +        }
>> +
>> +        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;
>> +    }
>> +
>> +}
>>
>> Propchange: 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange: 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java
>> ------------------------------------------------------------------------------
>>    svn:keywords = Author Date Id Revision
>>
>> Added: 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java
>> URL: 
>> http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java?rev=819974&view=auto
>> ==============================================================================
>> --- 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java
>>  (added)
>> +++ 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java
>>  Tue Sep 29 14:51:28 2009
>> @@ -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 );
>> +
>> +}
>>
>> Propchange: 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange: 
>> maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/plugin/ReportingConverter.java
>> ------------------------------------------------------------------------------
>>    svn:keywords = Author Date Id Revision
>>
>>
>>
>
>
>
> --
> Olivier
>



-- 
Olivier

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to