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 2021/03/15 19:08:47 UTC

[maven-resolver] branch 1.6.x_2 created (now ed304b2)

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

michaelo pushed a change to branch 1.6.x_2
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git.


      at ed304b2  [MRESOLVER-166] mark field final, as others

This branch includes the following new commits:

     new 85888c3  [MRESOLVER-165] Add support for mirror selector on external:http:*
     new 14f1b3a  [MRESOLVER-166] Add support for blocked repositories/mirrors
     new ed304b2  [MRESOLVER-166] mark field final, as others

The 3 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.



[maven-resolver] 02/03: [MRESOLVER-166] Add support for blocked repositories/mirrors

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

michaelo pushed a commit to branch 1.6.x_2
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit 14f1b3adf331cd16a61c2fa097b16ba8d763232b
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sun Mar 7 08:48:37 2021 +0100

    [MRESOLVER-166] Add support for blocked repositories/mirrors
---
 .../aether/repository/RemoteRepository.java        | 38 +++++++++++++++++++++-
 .../internal/impl/DefaultArtifactResolver.java     | 14 ++++++++
 .../util/repository/DefaultMirrorSelector.java     | 21 +++++++++---
 3 files changed, 68 insertions(+), 5 deletions(-)

diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
index eb57588..b234f2d 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
@@ -61,6 +61,8 @@ public final class RemoteRepository
 
     private final boolean repositoryManager;
 
+    private boolean blocked;
+
     RemoteRepository( Builder builder )
     {
         if ( builder.prototype != null )
@@ -78,6 +80,7 @@ public final class RemoteRepository
             repositoryManager =
                 ( builder.delta & Builder.REPOMAN ) != 0 ? builder.repositoryManager
                                 : builder.prototype.repositoryManager;
+            blocked = ( builder.delta & Builder.BLOCKED ) != 0 ? builder.blocked : builder.prototype.blocked;
             mirroredRepositories =
                 ( builder.delta & Builder.MIRRORED ) != 0 ? copy( builder.mirroredRepositories )
                                 : builder.prototype.mirroredRepositories;
@@ -92,6 +95,7 @@ public final class RemoteRepository
             proxy = builder.proxy;
             authentication = builder.authentication;
             repositoryManager = builder.repositoryManager;
+            blocked = builder.blocked;
             mirroredRepositories = copy( builder.mirroredRepositories );
         }
 
@@ -210,6 +214,16 @@ public final class RemoteRepository
         return repositoryManager;
     }
 
+    /**
+     * Indicates whether this repository is blocked from performing any download requests.
+     * 
+     * @return {@code true} if this repository is blocked from performing any download requests, {@code false} otherwise.
+     */
+    public boolean isBlocked()
+    {
+        return blocked;
+    }
+
     @Override
     public String toString()
     {
@@ -238,6 +252,10 @@ public final class RemoteRepository
         {
             buffer.append( ", managed" );
         }
+        if ( isBlocked() )
+        {
+            buffer.append( ", blocked" );
+        }
         buffer.append( ")" );
         return buffer.toString();
     }
@@ -294,7 +312,7 @@ public final class RemoteRepository
         private static final RepositoryPolicy DEFAULT_POLICY = new RepositoryPolicy();
 
         static final int ID = 0x0001, TYPE = 0x0002, URL = 0x0004, RELEASES = 0x0008, SNAPSHOTS = 0x0010,
-                        PROXY = 0x0020, AUTH = 0x0040, MIRRORED = 0x0080, REPOMAN = 0x0100;
+                        PROXY = 0x0020, AUTH = 0x0040, MIRRORED = 0x0080, REPOMAN = 0x0100, BLOCKED = 0x0200;
 
         int delta;
 
@@ -318,6 +336,8 @@ public final class RemoteRepository
 
         boolean repositoryManager;
 
+        boolean blocked;
+
         /**
          * Creates a new repository builder.
          * 
@@ -575,6 +595,22 @@ public final class RemoteRepository
             return this;
         }
 
+
+        /**
+         * Marks the repository as blocked or not.
+         * 
+         * @param blocked {@code true} if the repository should not be allowed to perform any requests.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setBlocked( boolean blocked )
+        {
+            this.blocked = blocked;
+            if ( prototype != null )
+            {
+                delta( BLOCKED, this.blocked, prototype.isBlocked() );
+            }
+            return this;
+        }
     }
 
 }
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java
index 4f63fc2..c703dfc 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultArtifactResolver.java
@@ -493,6 +493,20 @@ public class DefaultArtifactResolver
 
         try
         {
+            RemoteRepository repo = group.repository;
+            if ( repo.isBlocked() )
+            {
+                if ( repo.getMirroredRepositories().isEmpty() )
+                {
+                    throw new NoRepositoryConnectorException( repo, "Blocked repository: " + repo );
+                }
+                else
+                {
+                    throw new NoRepositoryConnectorException( repo, "Blocked mirror for repositories: "
+                        + repo.getMirroredRepositories() );
+                }
+            }
+
             try ( RepositoryConnector connector =
                           repositoryConnectorProvider.newRepositoryConnector( session, group.repository ) )
             {
diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java
index 83acad4..9dfa955 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java
@@ -41,6 +41,13 @@ public final class DefaultMirrorSelector
 
     private final List<MirrorDef> mirrors = new ArrayList<>();
 
+    @Deprecated
+    public DefaultMirrorSelector add( String id, String url, String type, boolean repositoryManager,
+                                      String mirrorOfIds, String mirrorOfTypes )
+    {
+        return add( id, url, type, repositoryManager, false, mirrorOfIds, mirrorOfTypes );
+    }
+
     /**
      * Adds the specified mirror to this selector.
      * 
@@ -48,6 +55,7 @@ public final class DefaultMirrorSelector
      * @param url The URL of the mirror, must not be {@code null}.
      * @param type The content type of the mirror, must not be {@code null}.
      * @param repositoryManager A flag whether the mirror is a repository manager or a simple server.
+     * @param blocked A flag whether the mirror is blocked from performing any download requests.
      * @param mirrorOfIds The identifier(s) of remote repositories to mirror, must not be {@code null}. Multiple
      *            identifiers can be separated by comma and additionally the wildcards "*", "external:http:*" and
      *            "external:*" can be used to match all (external) repositories, prefixing a repo id with an
@@ -57,10 +65,10 @@ public final class DefaultMirrorSelector
      *            wildcard "*" and the "!" negation syntax are supported. For example "*,!p2".
      * @return This selector for chaining, never {@code null}.
      */
-    public DefaultMirrorSelector add( String id, String url, String type, boolean repositoryManager,
+    public DefaultMirrorSelector add( String id, String url, String type, boolean repositoryManager, boolean blocked,
                                       String mirrorOfIds, String mirrorOfTypes )
     {
-        mirrors.add( new MirrorDef( id, url, type, repositoryManager, mirrorOfIds, mirrorOfTypes ) );
+        mirrors.add( new MirrorDef( id, url, type, repositoryManager, blocked, mirrorOfIds, mirrorOfTypes ) );
 
         return this;
     }
@@ -79,6 +87,8 @@ public final class DefaultMirrorSelector
 
         builder.setRepositoryManager( mirror.repositoryManager );
 
+        builder.setBlocked( mirror.blocked );
+
         if ( mirror.type != null && mirror.type.length() > 0 )
         {
             builder.setContentType( mirror.type );
@@ -285,17 +295,20 @@ public final class DefaultMirrorSelector
 
         final boolean repositoryManager;
 
+        final boolean blocked;
+
         final String mirrorOfIds;
 
         final String mirrorOfTypes;
 
-        MirrorDef( String id, String url, String type, boolean repositoryManager, String mirrorOfIds,
-                          String mirrorOfTypes )
+        MirrorDef( String id, String url, String type, boolean repositoryManager, boolean blocked, String mirrorOfIds,
+                   String mirrorOfTypes )
         {
             this.id = id;
             this.url = url;
             this.type = type;
             this.repositoryManager = repositoryManager;
+            this.blocked = blocked;
             this.mirrorOfIds = mirrorOfIds;
             this.mirrorOfTypes = mirrorOfTypes;
         }


[maven-resolver] 01/03: [MRESOLVER-165] Add support for mirror selector on external:http:*

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

michaelo pushed a commit to branch 1.6.x_2
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit 85888c3f5e4b6b3fec205d8d8e72571b9071b9af
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Mar 6 19:59:14 2021 +0100

    [MRESOLVER-165] Add support for mirror selector on external:http:*
---
 .../util/repository/DefaultMirrorSelector.java     | 39 ++++++++++++++++++----
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java
index 8ee2644..83acad4 100644
--- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java
+++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java
@@ -37,6 +37,8 @@ public final class DefaultMirrorSelector
 
     private static final String EXTERNAL_WILDCARD = "external:*";
 
+    private static final String EXTERNAL_HTTP_WILDCARD = "external:http:*";
+
     private final List<MirrorDef> mirrors = new ArrayList<>();
 
     /**
@@ -47,9 +49,9 @@ public final class DefaultMirrorSelector
      * @param type The content type of the mirror, must not be {@code null}.
      * @param repositoryManager A flag whether the mirror is a repository manager or a simple server.
      * @param mirrorOfIds The identifier(s) of remote repositories to mirror, must not be {@code null}. Multiple
-     *            identifiers can be separated by comma and additionally the wildcards "*" and "external:*" can be used
-     *            to match all (external) repositories, prefixing a repo id with an exclamation mark allows to express
-     *            an exclusion. For example "external:*,!central".
+     *            identifiers can be separated by comma and additionally the wildcards "*", "external:http:*" and
+     *            "external:*" can be used to match all (external) repositories, prefixing a repo id with an
+     *            exclamation mark allows to express an exclusion. For example "external:*,!central".
      * @param mirrorOfTypes The content type(s) of remote repositories to mirror, may be {@code null} or empty to match
      *            any content type. Similar to the repo id specification, multiple types can be comma-separated, the
      *            wildcard "*" and the "!" negation syntax are supported. For example "*,!p2".
@@ -123,6 +125,7 @@ public final class DefaultMirrorSelector
      * <ul>
      * <li>{@code *} = everything,</li>
      * <li>{@code external:*} = everything not on the localhost and not file based,</li>
+     * <li>{@code external:http:*} = any repository not on the localhost using HTTP,</li>
      * <li>{@code repo,repo1} = {@code repo} or {@code repo1},</li>
      * <li>{@code *,!repo1} = everything except {@code repo1}.</li>
      * </ul>
@@ -169,6 +172,12 @@ public final class DefaultMirrorSelector
                     result = true;
                     // don't stop processing in case a future segment explicitly excludes this repo
                 }
+                // check for external:http:*
+                else if ( EXTERNAL_HTTP_WILDCARD.equals( repo ) && isExternalHttpRepo( repository ) )
+                {
+                    result = true;
+                    // don't stop processing in case a future segment explicitly excludes this repo
+                }
                 else if ( WILDCARD.equals( repo ) )
                 {
                     result = true;
@@ -187,12 +196,30 @@ public final class DefaultMirrorSelector
      */
     static boolean isExternalRepo( RemoteRepository repository )
     {
-        boolean local =
-            "localhost".equals( repository.getHost() ) || "127.0.0.1".equals( repository.getHost() )
-                || "file".equalsIgnoreCase( repository.getProtocol() );
+        boolean local = isLocal( repository.getHost() ) || "file".equalsIgnoreCase( repository.getProtocol() );
         return !local;
     }
 
+    private static boolean isLocal( String host )
+    {
+        return "localhost".equals( host ) || "127.0.0.1".equals( host );
+    }
+
+    /**
+     * Checks the URL to see if this repository refers to a non-localhost repository using HTTP.
+     * 
+     * @param repository The repository to check, must not be {@code null}.
+     * @return {@code true} if external, {@code false} otherwise.
+     */
+    static boolean isExternalHttpRepo( RemoteRepository repository )
+    {
+        return ( "http".equalsIgnoreCase( repository.getProtocol() )
+            || "dav".equalsIgnoreCase( repository.getProtocol() )
+            || "dav:http".equalsIgnoreCase( repository.getProtocol() )
+            || "dav+http".equalsIgnoreCase( repository.getProtocol() ) )
+            && !isLocal( repository.getHost() );
+    }
+
     /**
      * Checks whether the types configured for a mirror match with the type of the repository.
      * 


[maven-resolver] 03/03: [MRESOLVER-166] mark field final, as others

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

michaelo pushed a commit to branch 1.6.x_2
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit ed304b284460069243b7c59335e26fb17452f94a
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sun Mar 14 21:44:19 2021 +0100

    [MRESOLVER-166] mark field final, as others
---
 .../src/main/java/org/eclipse/aether/repository/RemoteRepository.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
index b234f2d..1bf48e9 100644
--- a/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
+++ b/maven-resolver-api/src/main/java/org/eclipse/aether/repository/RemoteRepository.java
@@ -61,7 +61,7 @@ public final class RemoteRepository
 
     private final boolean repositoryManager;
 
-    private boolean blocked;
+    private final boolean blocked;
 
     RemoteRepository( Builder builder )
     {