You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/01/14 23:50:10 UTC

[maven-site-plugin] 01/01: [MSITE-920] Remove Maven 2 compat code

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MSITE-920
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit 28434462f0892398cebd0236e729d8c0fcda2acc
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Jan 15 00:49:21 2023 +0100

    [MSITE-920] Remove Maven 2 compat code
    
    This closes #121
---
 .../plugins/site/deploy/AbstractDeployMojo.java    | 73 ----------------------
 .../site/render/ReportDocumentRenderer.java        | 39 ------------
 2 files changed, 112 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
index d1067076..50647564 100644
--- a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
@@ -26,13 +26,11 @@ import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.DistributionManagement;
 import org.apache.maven.model.Site;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.site.AbstractSiteMojo;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Proxy;
-import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
 import org.apache.maven.settings.crypto.SettingsDecrypter;
@@ -52,17 +50,11 @@ import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.repository.Repository;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.codehaus.plexus.component.configurator.ComponentConfigurator;
-import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 import java.io.File;
 import java.net.MalformedURLException;
@@ -302,8 +294,6 @@ public abstract class AbstractDeployMojo
 
         try
         {
-            configureWagon( wagon, repository.getId(), settings, container, getLog() );
-
             SettingsDecrypter settingsDecrypter = container.lookup( SettingsDecrypter.class );
 
             ProxyInfo proxyInfo = getProxy( repository, settingsDecrypter );
@@ -319,10 +309,6 @@ public abstract class AbstractDeployMojo
         {
             throw new MojoExecutionException( "Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle );
         }
-        catch ( TransferFailedException e )
-        {
-            throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
-        }
         finally
         {
             try
@@ -623,65 +609,6 @@ public abstract class AbstractDeployMojo
         return null;
     }
 
-    /**
-     * Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
-     *
-     * @todo Remove when {@link WagonManager#getWagon(Repository) is available}. It's available in Maven 2.0.5.
-     */
-    private static void configureWagon( Wagon wagon, String repositoryId, Settings settings, PlexusContainer container,
-                                        Log log )
-        throws TransferFailedException
-    {
-        log.debug( " configureWagon " );
-
-        // MSITE-25: Make sure that the server settings are inserted
-        for ( Server server : settings.getServers() )
-        {
-            String id = server.getId();
-
-            log.debug( "configureWagon server " + id );
-
-            if ( id != null && id.equals( repositoryId ) && ( server.getConfiguration() != null ) )
-            {
-                final PlexusConfiguration plexusConf =
-                    new XmlPlexusConfiguration( (Xpp3Dom) server.getConfiguration() );
-
-                ComponentConfigurator componentConfigurator = null;
-                try
-                {
-                    componentConfigurator =
-                        (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "basic" );
-                    componentConfigurator.configureComponent( wagon, plexusConf, container.getContainerRealm() );
-                }
-                catch ( final ComponentLookupException e )
-                {
-                    throw new TransferFailedException(
-                        "While configuring wagon for \'" + repositoryId + "\': Unable to lookup wagon configurator."
-                            + " Wagon configuration cannot be applied.", e );
-                }
-                catch ( ComponentConfigurationException e )
-                {
-                    throw new TransferFailedException( "While configuring wagon for \'" + repositoryId
-                                                           + "\': Unable to apply wagon configuration.", e );
-                }
-                finally
-                {
-                    if ( componentConfigurator != null )
-                    {
-                        try
-                        {
-                            container.release( componentConfigurator );
-                        }
-                        catch ( ComponentLifecycleException e )
-                        {
-                            log.error( "Problem releasing configurator - ignoring: " + e.getMessage() );
-                        }
-                    }
-                }
-            }
-        }
-    }
-
     /**
      * {@inheritDoc}
      */
diff --git a/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java b/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java
index 40cf3ad0..83dfe9a2 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/ReportDocumentRenderer.java
@@ -26,8 +26,6 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Writer;
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Locale;
 import java.util.List;
@@ -224,10 +222,6 @@ public class ReportDocumentRenderer
                 // extended multi-page API
                 ( (MavenMultiPageReport) report ).generate( mainSink, multiPageSinkFactory, locale );
             }
-            else if ( generateMultiPage( locale, multiPageSinkFactory, mainSink ) )
-            {
-                // extended multi-page API for Maven 2.2, only accessible by reflection API
-            }
             else
             {
                 // old single-page-only API
@@ -311,39 +305,6 @@ public class ReportDocumentRenderer
         }
     }
 
-    /**
-     * Try to generate report with extended multi-page API.
-     *
-     * @return <code>true</code> if the report was compatible with the extended API
-     */
-    private boolean generateMultiPage( Locale locale, SinkFactory sf, Sink sink )
-        throws MavenReportException
-    {
-        try
-        {
-            // MavenMultiPageReport is not in Maven Core, then the class is different in site plugin and in each report
-            // plugin: only reflection can let us invoke its method
-            Method generate =
-                report.getClass().getMethod( "generate", Sink.class, SinkFactory.class, Locale.class );
-
-            generate.invoke( report, sink, sf, locale );
-
-            return true;
-        }
-        catch ( SecurityException se )
-        {
-            return false;
-        }
-        catch ( NoSuchMethodException nsme )
-        {
-            return false;
-        }
-        catch ( IllegalArgumentException | IllegalAccessException | InvocationTargetException ite )
-        {
-            throw new MavenReportException( "error while invoking generate on " + report.getClass(), ite );
-        }
-    }
-
     @Override
     public String getOutputName()
     {