From 1ab29f548535cb512d0e4726308b32fe4284e6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Thu, 25 Mar 2021 23:51:26 +0100 Subject: [PATCH] [MNG-7128] keep blocked attribute from mirrors in artifact repositories --- .../artifact/repository/ArtifactRepository.java | 6 ++++++ .../repository/DefaultArtifactRepository.java | 12 ++++++++++++ .../repository/legacy/LegacyRepositorySystem.java | 5 +++++ .../java/org/apache/maven/RepositoryUtils.java | 1 + .../repository/LegacyLocalRepositoryManager.java | 9 +++++++++ .../repository/MavenArtifactRepository.java | 14 ++++++++++++++ .../apache/maven/bridge/MavenRepositorySystem.java | 5 +++++ 7 files changed, 52 insertions(+) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java index 0b33345c73..47839eadc6 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java @@ -73,6 +73,12 @@ public interface ArtifactRepository @Deprecated void setBlacklisted( boolean blackListed ); + /** @since 3.8.1 **/ + boolean isBlocked(); + + /** @since 3.8.1 **/ + void setBlocked( boolean blocked ); + // // New interface methods for the repository system. // diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java index 16b82c5070..ef487b8ad3 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java @@ -54,6 +54,8 @@ public class DefaultArtifactRepository private List mirroredRepositories = Collections.emptyList(); + private boolean blocked; + /** * Create a local repository or a test repository. * @@ -264,4 +266,14 @@ public class DefaultArtifactRepository } } + public boolean isBlocked() + { + return blocked; + } + + public void setBlocked( boolean blocked ) + { + this.blocked = blocked; + } + } diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java index e4fff06dff..0bd821905d 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java @@ -440,6 +440,8 @@ public class LegacyRepositorySystem effectiveRepository.setMirroredRepositories( mirroredRepos ); + effectiveRepository.setBlocked( aliasedRepo.isBlocked() ); + effectiveRepositories.add( effectiveRepository ); } @@ -496,6 +498,7 @@ public class LegacyRepositorySystem mirror.setId( repo.getId() ); mirror.setUrl( repo.getUrl() ); mirror.setLayout( repo.getContentType() ); + mirror.setBlocked( repo.isBlocked() ); return mirror; } } @@ -532,6 +535,8 @@ public class LegacyRepositorySystem { repository.setLayout( getLayout( mirror.getLayout() ) ); } + + repository.setBlocked( mirror.isBlocked() ); } } diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java index 1f053810e5..1f4abfca71 100644 --- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java +++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java @@ -210,6 +210,7 @@ public class RepositoryUtils builder.setAuthentication( toAuthentication( repo.getAuthentication() ) ); builder.setProxy( toProxy( repo.getProxy() ) ); builder.setMirroredRepositories( toRepos( repo.getMirroredRepositories() ) ); + builder.setBlocked( repo.isBlocked() ); result = builder.build(); } return result; diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java index 634b63cefb..acd7d5f2c4 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java @@ -427,6 +427,15 @@ public class LegacyLocalRepositoryManager { } + public boolean isBlocked() + { + return false; + } + + public void setBlocked( boolean blocked ) + { + } + } } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java index 4463ca0a2c..ee513e4f73 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java @@ -59,6 +59,8 @@ public class MavenArtifactRepository private List mirroredRepositories = Collections.emptyList(); + private boolean blocked; + public MavenArtifactRepository() { } @@ -162,6 +164,8 @@ public class MavenArtifactRepository sb.append( ", update => " ).append( releases.getUpdatePolicy() ).append( ']' ); } + sb.append( " blocked: " ).append( isBlocked() ).append( '\n' ); + return sb.toString(); } @@ -416,4 +420,14 @@ public class MavenArtifactRepository } } + public boolean isBlocked() + { + return blocked; + } + + public void setBlocked( boolean blocked ) + { + this.blocked = blocked; + } + } diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java index e37db0428e..f6b83c002b 100644 --- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java +++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java @@ -199,6 +199,7 @@ public class MavenRepositorySystem mirror.setId( repo.getId() ); mirror.setUrl( repo.getUrl() ); mirror.setLayout( repo.getContentType() ); + mirror.setBlocked( repo.isBlocked() ); return mirror; } } @@ -235,6 +236,8 @@ public class MavenRepositorySystem { repository.setLayout( getLayout( mirror.getLayout() ) ); } + + repository.setBlocked( mirror.isBlocked() ); } } @@ -674,6 +677,8 @@ public class MavenRepositorySystem effectiveRepository.setMirroredRepositories( mirroredRepos ); + effectiveRepository.setBlocked( aliasedRepo.isBlocked() ); + effectiveRepositories.add( effectiveRepository ); }