diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 916a2c6047a..ad68c17ef7c 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -48,6 +48,7 @@ import org.gradle.api.artifacts.Dependency import org.gradle.api.artifacts.ModuleDependency import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.artifacts.repositories.ExclusiveContentRepository import org.gradle.api.artifacts.repositories.IvyArtifactRepository import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout import org.gradle.api.artifacts.repositories.MavenArtifactRepository @@ -350,10 +351,16 @@ class BuildPlugin implements Plugin { // extract the revision number from the version with a regex matcher List matches = (luceneVersion =~ /\w+-snapshot-([a-z0-9]+)/).getAt(0) as List String revision = matches.get(1) - repos.maven { MavenArtifactRepository repo -> + MavenArtifactRepository luceneRepo = repos.maven { MavenArtifactRepository repo -> repo.name = 'lucene-snapshots' repo.url = "https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/${revision}" } + repos.exclusiveContent { ExclusiveContentRepository exclusiveRepo -> + exclusiveRepo.filter { + it.includeVersionByRegex(/org\.apache\.lucene/, '.*', ".*-snapshot-${revision}") + } + exclusiveRepo.forRepositories(luceneRepo) + } } }