You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/05/02 11:34:23 UTC

[maven-site-plugin] branch MSITE-833 updated (5330906 -> 23c8b8c)

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

slachiewicz pushed a change to branch MSITE-833
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git.


 discard 5330906  [MSITE-833] Remove dependency to maven-compat
     add ef3addd  Updated testing matrix to include Java 16
     add 39b44d2  Bump junit to 4.13.2
     add 145ecb5  Bump slf4j to 1.7.29 (tests)
     add 15baa63  [MSITE-871] Use Javadoc plugin property
     add 7be9340  Bump surefire version to 2.22.2
     add 201104c  Bump maven-archiver from 3.5.0 to 3.5.1
     add 9b58d41  deps: update plexus-archiver to 4.2.4
     add 0a662b8  Bump maven-shared-utils from 3.1.0 to 3.3.3
     add eeb148b  Added Dependabot config
     add 69020b2  Bump plexus-archiver from 4.2.4 to 4.2.5 (#47)
     add e836af5  Clean up Jenkinsfile
     new 23c8b8c  [MSITE-833] Remove dependency to maven-compat

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5330906)
            \
             N -- N -- N   refs/heads/MSITE-833 (23c8b8c)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .asf.yaml => .github/dependabot.yml                | 39 ++++++++++++++--------
 Jenkinsfile                                        |  2 +-
 pom.xml                                            | 20 ++++++-----
 .../projects/MSITE-484/parent-usage-test/pom.xml   |  1 +
 src/it/projects/MSITE-484/pom.xml                  |  2 +-
 src/it/projects/MSITE-497/pom.xml                  |  4 +--
 src/it/projects/MSITE-506/pom.xml                  |  2 +-
 .../projects/MSITE-512/parent-usage-test/pom.xml   |  2 +-
 src/it/projects/MSITE-665/pom.xml                  |  2 +-
 src/it/projects/new-configuration/pom.xml          |  2 +-
 10 files changed, 46 insertions(+), 30 deletions(-)
 copy .asf.yaml => .github/dependabot.yml (57%)

[maven-site-plugin] 01/01: [MSITE-833] Remove dependency to maven-compat

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 23c8b8cdf1ea51163c03dd796c8cfd182dd0c28b
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Wed May 27 10:36:33 2020 +0200

    [MSITE-833] Remove dependency to maven-compat
---
 pom.xml                                            |   2 +-
 .../plugins/site/deploy/AbstractDeployMojo.java    | 187 ++++++---------------
 .../site/deploy/AbstractSiteDeployWebDavTest.java  |   7 +-
 .../plugins/site/deploy/SiteDeployMojoTest.java    |   7 +-
 4 files changed, 59 insertions(+), 144 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0cad68f..ae9b111 100644
--- a/pom.xml
+++ b/pom.xml
@@ -243,7 +243,7 @@ under the License.
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-compat</artifactId>
       <version>${mavenVersion}</version>
-      <scope>provided</scope>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
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 2355534..1bf58bf 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
@@ -19,7 +19,6 @@ package org.apache.maven.plugins.site.deploy;
  * under the License.
  */
 
-import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.doxia.site.decoration.inheritance.URIPathDescriptor;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
@@ -42,7 +41,6 @@ import org.apache.maven.wagon.CommandExecutor;
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.UnsupportedProtocolException;
 import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.authentication.AuthenticationException;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
@@ -50,7 +48,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.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
 import org.codehaus.plexus.component.configurator.ComponentConfigurator;
@@ -58,9 +55,6 @@ import org.codehaus.plexus.component.repository.exception.ComponentLifecycleExce
 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;
 
@@ -69,7 +63,8 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.List;
 import java.util.Locale;
-import java.util.Set;
+
+import static java.util.Locale.ENGLISH;
 
 /**
  * Abstract base class for deploy mojos.
@@ -80,7 +75,6 @@ import java.util.Set;
  */
 public abstract class AbstractDeployMojo
     extends AbstractSiteMojo
-    implements Contextualizable
 {
     /**
      * Directory containing the generated project sites and report distributions.
@@ -126,11 +120,6 @@ public abstract class AbstractDeployMojo
     private boolean skipDeploy;
 
     /**
-     */
-    @Component
-    private WagonManager wagonManager; // maven-compat
-
-    /**
      * The current user system settings for use in Maven.
      */
     @Parameter( defaultValue = "${settings}", readonly = true )
@@ -146,8 +135,13 @@ public abstract class AbstractDeployMojo
 
     private Site deploySite;
 
+    @Component
     private PlexusContainer container;
 
+    @Component
+    SettingsDecrypter settingsDecrypter;
+
+
     /**
      * {@inheritDoc}
      */
@@ -298,14 +292,12 @@ public abstract class AbstractDeployMojo
         throws MojoExecutionException
     {
         // TODO: work on moving this into the deployer like the other deploy methods
-        final Wagon wagon = getWagon( repository, wagonManager );
+        final Wagon wagon = getWagon( repository );
 
         try
         {
             configureWagon( wagon, repository.getId(), settings, container, getLog() );
 
-            SettingsDecrypter settingsDecrypter = container.lookup( SettingsDecrypter.class );
-
             ProxyInfo proxyInfo = getProxy( repository, settingsDecrypter );
 
             push( directory, repository, wagon, proxyInfo, getLocales(), getDeployModuleDirectory() );
@@ -315,10 +307,6 @@ public abstract class AbstractDeployMojo
                 chmod( wagon, repository, chmodOptions, chmodMode );
             }
         }
-        catch ( ComponentLookupException cle )
-        {
-            throw new MojoExecutionException( "Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle );
-        }
         catch ( TransferFailedException e )
         {
             throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
@@ -336,63 +324,68 @@ public abstract class AbstractDeployMojo
         }
     }
 
-    private Wagon getWagon( final Repository repository, final WagonManager manager )
+    private Wagon getWagon( final Repository repository )
         throws MojoExecutionException
     {
-        final Wagon wagon;
-
-        try
-        {
-            wagon = manager.getWagon( repository );
-        }
-        catch ( UnsupportedProtocolException e )
+        String protocol = repository.getProtocol();
+        if ( protocol == null )
         {
-            String shortMessage = "Unsupported protocol: '" + repository.getProtocol() + "' for site deployment to "
-                + "distributionManagement.site.url=" + repository.getUrl() + ".";
-            String longMessage =
-                "\n" + shortMessage + "\n" + "Currently supported protocols are: " + getSupportedProtocols() + ".\n"
-                    + "    Protocols may be added through wagon providers.\n" + "    For more information, see "
-                    + "https://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-protocol.html";
-
-            getLog().error( longMessage );
-
-            throw new MojoExecutionException( shortMessage );
+            throw new MojoExecutionException( "Unspecified protocol" );
         }
-        catch ( TransferFailedException e )
+        try
         {
-            throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
-        }
-
-        if ( !wagon.supportsDirectoryCopy() )
+            Wagon wagon = container.lookup( Wagon.class, protocol.toLowerCase( ENGLISH ) );
+            if ( !wagon.supportsDirectoryCopy() )
+            {
+                throw new MojoExecutionException(
+                        "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
+            }
+            return wagon;
+       }
+        catch ( ComponentLookupException e )
         {
-            throw new MojoExecutionException(
-                "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
+            throw new MojoExecutionException( "Cannot find wagon which supports the requested protocol: "
+                    + protocol, e );
         }
-
-        return wagon;
     }
 
-    private String getSupportedProtocols()
+    public AuthenticationInfo getAuthenticationInfo( String id )
     {
-        try
+        if ( id != null )
         {
-            Set<String> protocols = container.lookupMap( Wagon.class ).keySet();
+                List<Server> servers = settings.getServers();
 
-            return StringUtils.join( protocols.iterator(), ", " );
-        }
-        catch ( ComponentLookupException e )
-        {
-            // in the unexpected case there is a problem when instantiating a wagon provider
-            getLog().error( e );
+                if ( servers != null )
+                {
+                    for ( Server server : servers )
+                    {
+                        if ( id.equalsIgnoreCase( server.getId() ) )
+                        {
+                            SettingsDecryptionResult result =
+                                    settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( server ) );
+                            server = result.getServer();
+
+                            AuthenticationInfo authInfo = new AuthenticationInfo();
+                            authInfo.setUserName( server.getUsername() );
+                            authInfo.setPassword( server.getPassword() );
+                            authInfo.setPrivateKey( server.getPrivateKey() );
+                            authInfo.setPassphrase( server.getPassphrase() );
+
+                            return authInfo;
+                        }
+                    }
+            }
         }
-        return "";
+
+        // empty one to prevent NPE
+        return new AuthenticationInfo();
     }
 
     private void push( final File inputDirectory, final Repository repository, final Wagon wagon,
                        final ProxyInfo proxyInfo, final List<Locale> localesList, final String relativeDir )
         throws MojoExecutionException
     {
-        AuthenticationInfo authenticationInfo = wagonManager.getAuthenticationInfo( repository.getId() );
+        AuthenticationInfo authenticationInfo = getAuthenticationInfo( repository.getId() );
         getLog().debug( "authenticationInfo with id '" + repository.getId() + "': "
                             + ( ( authenticationInfo == null ) ? "-" : authenticationInfo.getUserName() ) );
 
@@ -412,7 +405,7 @@ public abstract class AbstractDeployMojo
                 getLog().debug( "connect with proxyInfo" );
                 wagon.connect( repository, authenticationInfo, proxyInfo );
             }
-            else if ( proxyInfo == null && authenticationInfo != null )
+            else if ( authenticationInfo != null )
             {
                 getLog().debug( "connect with authenticationInfo and without proxyInfo" );
                 wagon.connect( repository, authenticationInfo );
@@ -476,71 +469,6 @@ public abstract class AbstractDeployMojo
 
     /**
      * Get proxy information.
-     * <p>
-     * Get the <code>ProxyInfo</code> of the proxy associated with the <code>host</code>
-     * and the <code>protocol</code> of the given <code>repository</code>.
-     * </p>
-     * <p>
-     * 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 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
-     * @return a ProxyInfo object instantiated or <code>null</code> if no matching proxy is found
-     */
-    public static ProxyInfo getProxyInfo( Repository repository, WagonManager wagonManager )
-    {
-        ProxyInfo proxyInfo = wagonManager.getProxy( repository.getProtocol() );
-
-        if ( proxyInfo == null )
-        {
-            return null;
-        }
-
-        String host = repository.getHost();
-        String nonProxyHostsAsString = proxyInfo.getNonProxyHosts();
-        for ( String nonProxyHost : StringUtils.split( nonProxyHostsAsString, ",;|" ) )
-        {
-            if ( StringUtils.contains( nonProxyHost, "*" ) )
-            {
-                // Handle wildcard at the end, beginning or middle of the nonProxyHost
-                final int pos = nonProxyHost.indexOf( '*' );
-                String nonProxyHostPrefix = nonProxyHost.substring( 0, pos );
-                String nonProxyHostSuffix = nonProxyHost.substring( pos + 1 );
-                // prefix*
-                if ( StringUtils.isNotEmpty( nonProxyHostPrefix ) && host.startsWith( nonProxyHostPrefix )
-                    && StringUtils.isEmpty( nonProxyHostSuffix ) )
-                {
-                    return null;
-                }
-                // *suffix
-                if ( StringUtils.isEmpty( nonProxyHostPrefix ) && StringUtils.isNotEmpty( nonProxyHostSuffix )
-                    && host.endsWith( nonProxyHostSuffix ) )
-                {
-                    return null;
-                }
-                // prefix*suffix
-                if ( StringUtils.isNotEmpty( nonProxyHostPrefix ) && host.startsWith( nonProxyHostPrefix )
-                    && StringUtils.isNotEmpty( nonProxyHostSuffix ) && host.endsWith( nonProxyHostSuffix ) )
-                {
-                    return null;
-                }
-            }
-            else if ( host.equals( nonProxyHost ) )
-            {
-                return null;
-            }
-        }
-        return proxyInfo;
-    }
-
-    /**
-     * Get proxy information.
      *
      * @param repository        the Repository to extract the ProxyInfo from
      * @param settingsDecrypter settings password decrypter
@@ -626,7 +554,7 @@ public abstract class AbstractDeployMojo
     /**
      * 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.
+     * @todo Remove when {@link WagonManager#getWagon(String) is available}. It's available in Maven 2.0.5.
      */
     private static void configureWagon( Wagon wagon, String repositoryId, Settings settings, PlexusContainer container,
                                         Log log )
@@ -683,15 +611,6 @@ public abstract class AbstractDeployMojo
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public void contextualize( Context context )
-        throws ContextException
-    {
-        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
-    }
-
-    /**
      * Extract the distributionManagement site from the given MavenProject.
      *
      * @param project the MavenProject. Not null.
diff --git a/src/test/java/org/apache/maven/plugins/site/deploy/AbstractSiteDeployWebDavTest.java b/src/test/java/org/apache/maven/plugins/site/deploy/AbstractSiteDeployWebDavTest.java
index 1af75b1..61333b6 100644
--- a/src/test/java/org/apache/maven/plugins/site/deploy/AbstractSiteDeployWebDavTest.java
+++ b/src/test/java/org/apache/maven/plugins/site/deploy/AbstractSiteDeployWebDavTest.java
@@ -27,7 +27,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionRequest;
@@ -226,13 +226,10 @@ public abstract class AbstractSiteDeployWebDavTest
             }
             else
             {
-                ArtifactRepositoryFactory artifactRepositoryFactory = getContainer().lookup( ArtifactRepositoryFactory.class );
-
                 setVariableValueToObject( mojo, "stagingDirectory", inputDirectory );
                 setVariableValueToObject( mojo, "reactorProjects", Collections.emptyList() );
                 setVariableValueToObject( mojo, "localRepository",
-                                          artifactRepositoryFactory.createArtifactRepository( "local", "foo", "default",
-                                                                                              null, null ) );
+                        new MavenArtifactRepository("local", "foo", null, null, null) );
                 setVariableValueToObject( mojo, "siteTool", getContainer().lookup( SiteTool.class ) );
                 setVariableValueToObject( mojo, "siteDirectory", new File("foo") );
                 setVariableValueToObject( mojo, "repositories", Collections.emptyList() );
diff --git a/src/test/java/org/apache/maven/plugins/site/deploy/SiteDeployMojoTest.java b/src/test/java/org/apache/maven/plugins/site/deploy/SiteDeployMojoTest.java
index 59f41b4..623ec3b 100644
--- a/src/test/java/org/apache/maven/plugins/site/deploy/SiteDeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/site/deploy/SiteDeployMojoTest.java
@@ -19,8 +19,7 @@ package org.apache.maven.plugins.site.deploy;
  * under the License.
  */
 
-import org.apache.maven.artifact.manager.WagonManager;
-//import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.Wagon;
 import org.codehaus.plexus.PlexusTestCase;
 import org.junit.Before;
 import org.junit.Test;
@@ -34,7 +33,7 @@ import org.junit.runners.JUnit4;
 public class SiteDeployMojoTest
     extends PlexusTestCase
 {
-    private WagonManager wagonManager;
+    private Wagon wagon;
 
     //private Repository repository;
 
@@ -43,7 +42,7 @@ public class SiteDeployMojoTest
         throws Exception
     {
         super.setUp();
-        wagonManager = getContainer().lookup( WagonManager.class );
+        // wagon = getContainer().lookup( Wagon.class, "scp" );
         //repository = new Repository( "my-repository", "scp://repository-host/var/maven2" );
     }