You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/05/24 11:45:52 UTC
[maven-site-plugin] 01/01: -a
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch plex
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git
commit 8f8d1857a5f7dd47ac11dc62cc7b057775b6c78f
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sun May 24 07:45:33 2020 -0400
-a
remove Maven 2 support
---
.../plugins/site/deploy/AbstractDeployMojo.java | 58 +++-------------------
.../site/render/AbstractSiteRenderingMojo.java | 43 ++++++----------
.../site/render/ReportDocumentRenderer.java | 49 ++----------------
3 files changed, 24 insertions(+), 126 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 ac262cd..99748c9 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
@@ -51,7 +51,6 @@ import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.observers.Debug;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.classworlds.ClassRealm;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
@@ -67,7 +66,6 @@ import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
-import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
@@ -501,16 +499,16 @@ public abstract class AbstractDeployMojo
* and the <code>protocol</code> of the given <code>repository</code>.
* </p>
* <p>
- * Extract from <a href="http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html">
+ * Extract from <a href="https://docs.oracle.com/javase/1.5.0/docs/guide/net/properties.html">
* J2SE Doc : Networking Properties - nonProxyHosts</a> : "The value can be a list of hosts,
* each separated by a |, and in addition a wildcard character (*) can be used for matching"
* </p>
* <p>
- * Defensively support for comma (",") and semi colon (";") in addition to pipe ("|") as separator.
+ * Defensively support comma (",") and semi colon (";") in addition to pipe ("|") as separator.
* </p>
*
- * @param repository the Repository to extract the ProxyInfo from.
- * @param wagonManager the WagonManager used to connect to the Repository.
+ * @param repository the Repository to extract the ProxyInfo from
+ * @param wagonManager the WagonManager used to connect to the Repository
* @return a ProxyInfo object instantiated or <code>null</code> if no matching proxy is found
*/
public static ProxyInfo getProxyInfo( Repository repository, WagonManager wagonManager )
@@ -560,11 +558,7 @@ public abstract class AbstractDeployMojo
}
/**
- * Get proxy information for Maven 3.
- *
- * @param repository
- * @param settingsDecrypter
- * @return
+ * Get proxy information.
*/
private ProxyInfo getProxy( Repository repository, SettingsDecrypter settingsDecrypter )
{
@@ -646,12 +640,6 @@ public abstract class AbstractDeployMojo
/**
* Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
*
- * @param wagon
- * @param repositoryId
- * @param settings
- * @param container
- * @param log
- * @throws TransferFailedException
* @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,
@@ -677,15 +665,8 @@ public abstract class AbstractDeployMojo
{
componentConfigurator =
(ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "basic" );
- if ( isMaven3OrMore() )
- {
- componentConfigurator.configureComponent( wagon, plexusConf,
+ componentConfigurator.configureComponent( wagon, plexusConf,
container.getContainerRealm() );
- }
- else
- {
- configureWagonWithMaven2( componentConfigurator, wagon, plexusConf, container );
- }
}
catch ( final ComponentLookupException e )
{
@@ -716,33 +697,6 @@ public abstract class AbstractDeployMojo
}
}
- private static void configureWagonWithMaven2( ComponentConfigurator componentConfigurator, Wagon wagon,
- PlexusConfiguration plexusConf, PlexusContainer container )
- throws ComponentConfigurationException
- {
- // in Maven 2.x :
- // * container.getContainerRealm() -> org.codehaus.classworlds.ClassRealm
- // * componentConfiguration 3rd param is org.codehaus.classworlds.ClassRealm
- // so use some reflection see MSITE-609
- try
- {
- Method methodContainerRealm = container.getClass().getMethod( "getContainerRealm" );
- ClassRealm realm = (ClassRealm) methodContainerRealm.invoke( container );
-
- Method methodConfigure = componentConfigurator.getClass().getMethod( "configureComponent",
- new Class[]{ Object.class,
- PlexusConfiguration.class,
- ClassRealm.class } );
-
- methodConfigure.invoke( componentConfigurator, wagon, plexusConf, realm );
- }
- catch ( Exception e )
- {
- throw new ComponentConfigurationException(
- "Failed to configure wagon component for a Maven2 use " + e.getMessage(), e );
- }
- }
-
/**
* {@inheritDoc}
*/
diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index 7336d0f..5b62aa6 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -230,40 +230,25 @@ public abstract class AbstractSiteRenderingMojo
protected List<MavenReportExecution> getReports()
throws MojoExecutionException
{
- final List<MavenReportExecution> allReports;
- if ( isMaven3OrMore() )
+ MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
+ mavenReportExecutorRequest.setLocalRepository( localRepository );
+ mavenReportExecutorRequest.setMavenSession( mavenSession );
+ mavenReportExecutorRequest.setProject( project );
+ mavenReportExecutorRequest.setReportPlugins( getReportingPlugins() );
+
+ MavenReportExecutor mavenReportExecutor;
+ try
{
- // Maven 3
- MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
- mavenReportExecutorRequest.setLocalRepository( localRepository );
- mavenReportExecutorRequest.setMavenSession( mavenSession );
- mavenReportExecutorRequest.setProject( project );
- mavenReportExecutorRequest.setReportPlugins( getReportingPlugins() );
-
- MavenReportExecutor mavenReportExecutor;
- try
- {
- mavenReportExecutor = container.lookup( MavenReportExecutor.class );
- }
- catch ( ComponentLookupException e )
- {
- throw new MojoExecutionException( "could not get MavenReportExecutor component", e );
- }
-
- allReports = mavenReportExecutor.buildMavenReports( mavenReportExecutorRequest );
+ mavenReportExecutor = container.lookup( MavenReportExecutor.class );
}
- else
+ catch ( ComponentLookupException e )
{
- // Maven 2
- allReports = new ArrayList<>( reports.size() );
- for ( MavenReport report : reports )
- {
- allReports.add( new MavenReportExecution( report ) );
- }
+ throw new MojoExecutionException( "could not get MavenReportExecutor component", e );
}
+ List<MavenReportExecution> allReports = mavenReportExecutor.buildMavenReports( mavenReportExecutorRequest );
+
// filter out reports that can't be generated
- // todo Lambda Java 1.8
List<MavenReportExecution> reportExecutions = new ArrayList<>( allReports.size() );
for ( MavenReportExecution exec : allReports )
{
@@ -276,7 +261,7 @@ public abstract class AbstractSiteRenderingMojo
}
/**
- * Get the report plugins from reporting section, adding if necessary (ni.e. not excluded)
+ * Get the report plugins from reporting section, adding if necessary (i.e. not excluded)
* default reports (i.e. maven-project-info-reports)
*
* @return the effective list of reports
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 dcf6e07..e59a023 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
@@ -76,57 +76,16 @@ public class ReportDocumentRenderer
this.renderingContext = renderingContext;
- if ( mavenReportExecution.getPlugin() == null )
- {
- // Maven 2: report has been prepared in Maven Core, MavenReportExecution contains only the report
- this.reportMojoInfo = getPluginInfo( report );
- }
- else
- {
- // Maven 3: full MavenReportExecution prepared by maven-reporting-impl
- this.reportMojoInfo =
- mavenReportExecution.getPlugin().getArtifactId() + ':' + mavenReportExecution.getPlugin().getVersion()
- + ':' + mavenReportExecution.getGoal();
- }
+ // full MavenReportExecution prepared by maven-reporting-impl
+ this.reportMojoInfo =
+ mavenReportExecution.getPlugin().getArtifactId() + ':' + mavenReportExecution.getPlugin().getVersion()
+ + ':' + mavenReportExecution.getGoal();
this.classLoader = mavenReportExecution.getClassLoader();
this.log = log;
}
- /**
- * Get plugin information from report's Manifest.
- *
- * @param report the Maven report
- * @return plugin information as Specification Title followed by Specification Version if set in Manifest and
- * supported by JVM
- */
- private String getPluginInfo( MavenReport report )
- {
- Package pkg = report.getClass().getPackage();
-
- if ( pkg != null )
- {
- String title = pkg.getSpecificationTitle();
- String version = pkg.getSpecificationVersion();
-
- if ( title == null )
- {
- return version;
- }
- else if ( version == null )
- {
- return title;
- }
- else
- {
- return title + ' ' + version;
- }
- }
-
- return null;
- }
-
private static class MultiPageSubSink
extends SiteRendererSink
{