diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java index 83c37e43778..24888e683f6 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java @@ -183,24 +183,21 @@ public class DistributionDownloadPlugin implements Plugin { } private static void addIvyRepo(Project project, String name, String url, String group) { - project.getRepositories().ivy(ivyRepo -> { - ivyRepo.setName(name); - ivyRepo.setUrl(url); - ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact); + IvyArtifactRepository ivyRepo = project.getRepositories().ivy(repo -> { + repo.setName(name); + repo.setUrl(url); + repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact); // this header is not a credential but we hack the capability to send this header to avoid polluting our download stats - ivyRepo.credentials(HttpHeaderCredentials.class, creds -> { + repo.credentials(HttpHeaderCredentials.class, creds -> { creds.setName("X-Elastic-No-KPI"); creds.setValue("1"); }); - ivyRepo.getAuthentication().create("header", HttpHeaderAuthentication.class); - ivyRepo.patternLayout(layout -> layout.artifact("/downloads/elasticsearch/[module]-[revision](-[classifier]).[ext]")); - ivyRepo.content(content -> content.includeGroup(group)); + repo.getAuthentication().create("header", HttpHeaderAuthentication.class); + repo.patternLayout(layout -> layout.artifact("/downloads/elasticsearch/[module]-[revision](-[classifier]).[ext]")); }); - project.getRepositories().all(repo -> { - if (repo.getName().equals(name) == false) { - // all other repos should ignore the special group name - repo.content(content -> content.excludeGroup(group)); - } + project.getRepositories().exclusiveContent(exclusiveContentRepository -> { + exclusiveContentRepository.filter(config -> config.includeGroup(group)); + exclusiveContentRepository.forRepositories(ivyRepo); }); } diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java index 9c48fd8ac1b..11167d3d3e2 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/JdkDownloadPlugin.java @@ -79,16 +79,6 @@ public class JdkDownloadPlugin implements Plugin { setupRootJdkDownload(project.getRootProject(), jdk); } }); - - // all other repos should ignore the special jdk artifacts - project.getRootProject().getRepositories().all(repo -> { - if (repo.getName().startsWith(REPO_NAME_PREFIX) == false) { - repo.content(content -> { - content.excludeGroup("adoptopenjdk"); - content.excludeGroup("openjdk"); - }); - } - }); } @SuppressWarnings("unchecked") @@ -145,13 +135,16 @@ public class JdkDownloadPlugin implements Plugin { } // Define the repository if we haven't already - if (rootProject.getRepositories().findByName(repoName) == null) { - repositories.ivy(ivyRepo -> { - ivyRepo.setName(repoName); - ivyRepo.setUrl(repoUrl); - ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact); - ivyRepo.patternLayout(layout -> layout.artifact(artifactPattern)); - ivyRepo.content(content -> content.includeGroup(jdk.getVendor())); + if (repositories.findByName(repoName) == null) { + IvyArtifactRepository ivyRepo = repositories.ivy(repo -> { + repo.setName(repoName); + repo.setUrl(repoUrl); + repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact); + repo.patternLayout(layout -> layout.artifact(artifactPattern)); + }); + repositories.exclusiveContent(exclusiveContentRepository -> { + exclusiveContentRepository.forRepositories(ivyRepo); + exclusiveContentRepository.filter(config -> config.includeGroup(groupName(jdk))); }); } @@ -261,7 +254,11 @@ public class JdkDownloadPlugin implements Plugin { : jdk.getPlatform(); String extension = jdk.getPlatform().equals("windows") ? "zip" : "tar.gz"; - return jdk.getVendor() + ":" + platformDep + ":" + jdk.getBaseVersion() + "@" + extension; + return groupName(jdk) + ":" + platformDep + ":" + jdk.getBaseVersion() + "@" + extension; + } + + private static String groupName(Jdk jdk) { + return jdk.getVendor() + "_" + jdk.getMajor(); } private static String configName(String... parts) {