Skip to content

Commit 16a2c42

Browse files
authored
Provide names for all artifact repositories (#41857)
This commit adds a name for each Maven and Ivy repository used in the build.
1 parent 3eb8575 commit 16a2c42

File tree

20 files changed

+33
-7
lines changed

20 files changed

+33
-7
lines changed

.ci/init.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA
66
settings.pluginManagement {
77
repositories {
88
maven {
9+
name "artifactory-gradle-plugins"
910
url "https://artifactory.elstc.co/artifactory/gradle-plugins"
1011
credentials {
1112
username System.env.ELASTIC_ARTIFACTORY_USERNAME
@@ -21,6 +22,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA
2122
buildscript {
2223
repositories {
2324
maven {
25+
name "artifactory-gradle-release"
2426
url "https://artifactory.elstc.co/artifactory/gradle-release/"
2527
credentials {
2628
username System.env.ELASTIC_ARTIFACTORY_USERNAME
@@ -31,6 +33,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA
3133
}
3234
repositories {
3335
maven {
36+
name "artifactory-gradle-release"
3437
url "https://artifactory.elstc.co/artifactory/gradle-release/"
3538
credentials {
3639
username System.env.ELASTIC_ARTIFACTORY_USERNAME

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ subprojects {
8888
}
8989
repositories {
9090
maven {
91-
name = 'localTest'
91+
name = 'test'
9292
url = "${rootProject.buildDir}/local-test-repo"
9393
}
9494
}

buildSrc/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ if (project != rootProject) {
189189
task integTest(type: Test) {
190190
// integration test requires the local testing repo for example plugin builds
191191
dependsOn project.rootProject.allprojects.collect {
192-
it.tasks.matching { it.name == 'publishNebulaPublicationToLocalTestRepository'}
192+
it.tasks.matching { it.name == 'publishNebulaPublicationToTestRepository'}
193193
}
194194
dependsOn setupLocalDownloads
195195
exclude "**/*Tests.class"

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.gradle.api.artifacts.ModuleVersionIdentifier
3939
import org.gradle.api.artifacts.ProjectDependency
4040
import org.gradle.api.artifacts.ResolvedArtifact
4141
import org.gradle.api.artifacts.dsl.RepositoryHandler
42+
import org.gradle.api.artifacts.repositories.ArtifactRepository
4243
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
4344
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
4445
import org.gradle.api.credentials.HttpHeaderCredentials
@@ -585,11 +586,11 @@ class BuildPlugin implements Plugin<Project> {
585586
project.getRepositories().all { repository ->
586587
if (repository instanceof MavenArtifactRepository) {
587588
final MavenArtifactRepository maven = (MavenArtifactRepository) repository
588-
assertRepositoryURIUsesHttps(project, maven.getUrl())
589+
assertRepositoryURIUsesHttps(maven, project, maven.getUrl())
589590
repository.getArtifactUrls().each { uri -> assertRepositoryURIUsesHttps(project, uri) }
590591
} else if (repository instanceof IvyArtifactRepository) {
591592
final IvyArtifactRepository ivy = (IvyArtifactRepository) repository
592-
assertRepositoryURIUsesHttps(project, ivy.getUrl())
593+
assertRepositoryURIUsesHttps(ivy, project, ivy.getUrl())
593594
}
594595
}
595596
RepositoryHandler repos = project.repositories
@@ -601,6 +602,7 @@ class BuildPlugin implements Plugin<Project> {
601602
}
602603
repos.jcenter()
603604
repos.ivy {
605+
name "elasticsearch"
604606
url "https://artifacts.elastic.co/downloads"
605607
patternLayout {
606608
artifact "elasticsearch/[module]-[revision](-[classifier]).[ext]"
@@ -629,9 +631,9 @@ class BuildPlugin implements Plugin<Project> {
629631
}
630632
}
631633

632-
private static void assertRepositoryURIUsesHttps(final Project project, final URI uri) {
634+
private static void assertRepositoryURIUsesHttps(final ArtifactRepository repository, final Project project, final URI uri) {
633635
if (uri != null && uri.toURL().getProtocol().equals("http")) {
634-
throw new GradleException("repository on project with path [${project.path}] is using http for artifacts on [${uri.toURL()}]")
636+
throw new GradleException("repository [${repository.name}] on project with path [${project.path}] is using http for artifacts on [${uri.toURL()}]")
635637
}
636638
}
637639

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class VagrantTestPlugin implements Plugin<Project> {
174174
which should work for 5.0.0+. This isn't a real ivy repository but gradle
175175
is fine with that */
176176
repos.ivy {
177+
name "elasticsearch"
177178
artifactPattern "https://artifacts.elastic.co/downloads/elasticsearch/[module]-[revision].[ext]"
178179
}
179180
}

buildSrc/src/test/java/org/elasticsearch/gradle/BuildExamplePluginsIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ private void adaptBuildScriptForTest() throws IOException {
9999
"buildscript {\n" +
100100
" repositories {\n" +
101101
" maven {\n" +
102+
" name = \"test\"\n" +
102103
" url = '" + getLocalTestRepoPath() + "'\n" +
103104
" }\n" +
104105
" }\n" +
@@ -117,12 +118,14 @@ private void adaptBuildScriptForTest() throws IOException {
117118
String luceneSnapshotRevision = System.getProperty("test.lucene-snapshot-revision");
118119
if (luceneSnapshotRepo != null) {
119120
luceneSnapshotRepo = " maven {\n" +
121+
" name \"lucene-snapshots\"\n" +
120122
" url \"https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/" + luceneSnapshotRevision + "\"\n" +
121123
" }\n";
122124
}
123125
writeBuildScript("\n" +
124126
"repositories {\n" +
125127
" maven {\n" +
128+
" name \"test\"\n" +
126129
" url \"" + getLocalTestRepoPath() + "\"\n" +
127130
" }\n" +
128131
" flatDir {\n" +

buildSrc/src/testKit/elasticsearch.build/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ repositories {
1616
jcenter()
1717
repositories {
1818
maven {
19+
name "local-repo"
1920
url System.getProperty("local.repo.path")
2021
}
2122
}

buildSrc/src/testKit/jarHell/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ repositories {
1515
jcenter()
1616
repositories {
1717
maven {
18+
name "local"
1819
url System.getProperty("local.repo.path")
1920
}
2021
}

buildSrc/src/testKit/testclusters/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ allprojects { all ->
99
dir System.getProperty("test.local-test-downloads-path")
1010
}
1111
maven {
12+
name "local"
1213
url System.getProperty("local.repo.path")
1314
}
1415
String luceneSnapshotRevision = System.getProperty("test.lucene-snapshot-revision")
1516
if (luceneSnapshotRevision != null) {
1617
maven {
18+
name "lucene-snapshots"
1719
url "https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/" + luceneSnapshotRevision
1820
}
1921
}

buildSrc/src/testKit/thirdPartyAudit/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repositories {
1414
* - version 0.0.2 has the same class and one extra file just to make the jar different
1515
*/
1616
maven {
17+
name = "local-test"
1718
url = file("sample_jars/build/testrepo")
1819
}
1920
jcenter()

0 commit comments

Comments
 (0)