From d7fd51a84e726b237623e2a4e3ab37b193cf3b09 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 7 May 2019 06:34:51 -0400 Subject: [PATCH] Provide names for all artifact repositories (#41857) This commit adds a name for each Maven and Ivy repository used in the build. --- .ci/init.gradle | 3 +++ build.gradle | 2 +- buildSrc/build.gradle | 2 +- .../groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 10 ++++++---- .../gradle/vagrant/VagrantTestPlugin.groovy | 1 + .../elasticsearch/gradle/BuildExamplePluginsIT.java | 3 +++ buildSrc/src/testKit/elasticsearch.build/build.gradle | 1 + buildSrc/src/testKit/jarHell/build.gradle | 1 + buildSrc/src/testKit/testclusters/build.gradle | 2 ++ buildSrc/src/testKit/thirdPartyAudit/build.gradle | 1 + distribution/build.gradle | 2 ++ distribution/packages/build.gradle | 1 + docs/java-api/index.asciidoc | 1 + docs/java-rest/high-level/getting-started.asciidoc | 1 + docs/reference/setup/setup-xclient.asciidoc | 1 + qa/build.gradle | 2 ++ qa/wildfly/build.gradle | 1 + x-pack/docs/en/watcher/java.asciidoc | 1 + x-pack/plugin/ml/build.gradle | 2 +- x-pack/qa/rolling-upgrade-basic/build.gradle | 2 ++ 20 files changed, 33 insertions(+), 7 deletions(-) diff --git a/.ci/init.gradle b/.ci/init.gradle index 62e6c48b812..ec16b49bfab 100644 --- a/.ci/init.gradle +++ b/.ci/init.gradle @@ -6,6 +6,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA settings.pluginManagement { repositories { maven { + name "artifactory-gradle-plugins" url "https://artifactory.elstc.co/artifactory/gradle-plugins" credentials { username System.env.ELASTIC_ARTIFACTORY_USERNAME @@ -21,6 +22,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA buildscript { repositories { maven { + name "artifactory-gradle-release" url "https://artifactory.elstc.co/artifactory/gradle-release/" credentials { username System.env.ELASTIC_ARTIFACTORY_USERNAME @@ -31,6 +33,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA } repositories { maven { + name "artifactory-gradle-release" url "https://artifactory.elstc.co/artifactory/gradle-release/" credentials { username System.env.ELASTIC_ARTIFACTORY_USERNAME diff --git a/build.gradle b/build.gradle index 3cd35d2a5d4..c28a1896912 100644 --- a/build.gradle +++ b/build.gradle @@ -88,7 +88,7 @@ subprojects { } repositories { maven { - name = 'localTest' + name = 'test' url = "${rootProject.buildDir}/local-test-repo" } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 3ff07564b5b..3c7f89ab972 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -200,7 +200,7 @@ if (project != rootProject) { task integTest(type: Test) { // integration test requires the local testing repo for example plugin builds dependsOn project.rootProject.allprojects.collect { - it.tasks.matching { it.name == 'publishNebulaPublicationToLocalTestRepository'} + it.tasks.matching { it.name == 'publishNebulaPublicationToTestRepository'} } dependsOn setupLocalDownloads exclude "**/*Tests.class" diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 898da980689..0357c2f76ef 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -39,6 +39,7 @@ import org.gradle.api.artifacts.ModuleVersionIdentifier import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.ResolvedArtifact import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.artifacts.repositories.ArtifactRepository import org.gradle.api.artifacts.repositories.IvyArtifactRepository import org.gradle.api.artifacts.repositories.MavenArtifactRepository import org.gradle.api.credentials.HttpHeaderCredentials @@ -585,11 +586,11 @@ class BuildPlugin implements Plugin { project.getRepositories().all { repository -> if (repository instanceof MavenArtifactRepository) { final MavenArtifactRepository maven = (MavenArtifactRepository) repository - assertRepositoryURIUsesHttps(project, maven.getUrl()) + assertRepositoryURIUsesHttps(maven, project, maven.getUrl()) repository.getArtifactUrls().each { uri -> assertRepositoryURIUsesHttps(project, uri) } } else if (repository instanceof IvyArtifactRepository) { final IvyArtifactRepository ivy = (IvyArtifactRepository) repository - assertRepositoryURIUsesHttps(project, ivy.getUrl()) + assertRepositoryURIUsesHttps(ivy, project, ivy.getUrl()) } } RepositoryHandler repos = project.repositories @@ -601,6 +602,7 @@ class BuildPlugin implements Plugin { } repos.jcenter() repos.ivy { + name "elasticsearch" url "https://artifacts.elastic.co/downloads" patternLayout { artifact "elasticsearch/[module]-[revision](-[classifier]).[ext]" @@ -629,9 +631,9 @@ class BuildPlugin implements Plugin { } } - private static void assertRepositoryURIUsesHttps(final Project project, final URI uri) { + private static void assertRepositoryURIUsesHttps(final ArtifactRepository repository, final Project project, final URI uri) { if (uri != null && uri.toURL().getProtocol().equals("http")) { - throw new GradleException("repository on project with path [${project.path}] is using http for artifacts on [${uri.toURL()}]") + throw new GradleException("repository [${repository.name}] on project with path [${project.path}] is using http for artifacts on [${uri.toURL()}]") } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy index 093733fe844..0262c7d8151 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy @@ -174,6 +174,7 @@ class VagrantTestPlugin implements Plugin { which should work for 5.0.0+. This isn't a real ivy repository but gradle is fine with that */ repos.ivy { + name "elasticsearch" artifactPattern "https://artifacts.elastic.co/downloads/elasticsearch/[module]-[revision].[ext]" } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/BuildExamplePluginsIT.java b/buildSrc/src/test/java/org/elasticsearch/gradle/BuildExamplePluginsIT.java index ee8e94c0e1e..762bcc5ff9b 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/BuildExamplePluginsIT.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/BuildExamplePluginsIT.java @@ -99,6 +99,7 @@ public class BuildExamplePluginsIT extends GradleIntegrationTestCase { "buildscript {\n" + " repositories {\n" + " maven {\n" + + " name = \"test\"\n" + " url = '" + getLocalTestRepoPath() + "'\n" + " }\n" + " }\n" + @@ -117,12 +118,14 @@ public class BuildExamplePluginsIT extends GradleIntegrationTestCase { String luceneSnapshotRevision = System.getProperty("test.lucene-snapshot-revision"); if (luceneSnapshotRepo != null) { luceneSnapshotRepo = " maven {\n" + + " name \"lucene-snapshots\"\n" + " url \"https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/" + luceneSnapshotRevision + "\"\n" + " }\n"; } writeBuildScript("\n" + "repositories {\n" + " maven {\n" + + " name \"test\"\n" + " url \"" + getLocalTestRepoPath() + "\"\n" + " }\n" + " flatDir {\n" + diff --git a/buildSrc/src/testKit/elasticsearch.build/build.gradle b/buildSrc/src/testKit/elasticsearch.build/build.gradle index 8020935f67e..7a68fe59baa 100644 --- a/buildSrc/src/testKit/elasticsearch.build/build.gradle +++ b/buildSrc/src/testKit/elasticsearch.build/build.gradle @@ -16,6 +16,7 @@ repositories { jcenter() repositories { maven { + name "local-repo" url System.getProperty("local.repo.path") } } diff --git a/buildSrc/src/testKit/jarHell/build.gradle b/buildSrc/src/testKit/jarHell/build.gradle index cd423c9f99f..cb12ce03f51 100644 --- a/buildSrc/src/testKit/jarHell/build.gradle +++ b/buildSrc/src/testKit/jarHell/build.gradle @@ -15,6 +15,7 @@ repositories { jcenter() repositories { maven { + name "local" url System.getProperty("local.repo.path") } } diff --git a/buildSrc/src/testKit/testclusters/build.gradle b/buildSrc/src/testKit/testclusters/build.gradle index d0a2eb4c305..e4f912a3d7a 100644 --- a/buildSrc/src/testKit/testclusters/build.gradle +++ b/buildSrc/src/testKit/testclusters/build.gradle @@ -9,11 +9,13 @@ allprojects { all -> dir System.getProperty("test.local-test-downloads-path") } maven { + name "local" url System.getProperty("local.repo.path") } String luceneSnapshotRevision = System.getProperty("test.lucene-snapshot-revision") if (luceneSnapshotRevision != null) { maven { + name "lucene-snapshots" url "https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/" + luceneSnapshotRevision } } diff --git a/buildSrc/src/testKit/thirdPartyAudit/build.gradle b/buildSrc/src/testKit/thirdPartyAudit/build.gradle index 42e0a22ccea..725be970fd9 100644 --- a/buildSrc/src/testKit/thirdPartyAudit/build.gradle +++ b/buildSrc/src/testKit/thirdPartyAudit/build.gradle @@ -14,6 +14,7 @@ repositories { * - version 0.0.2 has the same class and one extra file just to make the jar different */ maven { + name = "local-test" url = file("sample_jars/build/testrepo") } jcenter() diff --git a/distribution/build.gradle b/distribution/build.gradle index 122b8863d5e..d1160a06194 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -237,6 +237,7 @@ String hash = jdkVersionMatcher.group(4) repositories { // simpler legacy pattern from JDK 9 to JDK 12 that we are advocating to Oracle to bring back ivy { + name "legacy-jdk" url "https://download.oracle.com" metadataSources { artifact() @@ -247,6 +248,7 @@ repositories { } // current pattern since 12.0.1 ivy { + name "jdk" url "https://download.oracle.com" metadataSources { artifact() diff --git a/distribution/packages/build.gradle b/distribution/packages/build.gradle index af1479d360c..6acef5adc53 100644 --- a/distribution/packages/build.gradle +++ b/distribution/packages/build.gradle @@ -53,6 +53,7 @@ import java.util.regex.Pattern buildscript { repositories { maven { + name "gradle-plugins" url "https://plugins.gradle.org/m2/" } } diff --git a/docs/java-api/index.asciidoc b/docs/java-api/index.asciidoc index 764d53d4817..4a7fd7482d2 100644 --- a/docs/java-api/index.asciidoc +++ b/docs/java-api/index.asciidoc @@ -68,6 +68,7 @@ For Gradle: ["source","groovy",subs="attributes"] -------------------------------------------------- maven { + name "lucene-snapshots" url 'https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/00142c9' } -------------------------------------------------- diff --git a/docs/java-rest/high-level/getting-started.asciidoc b/docs/java-rest/high-level/getting-started.asciidoc index 5ef28d7fc86..89912cc2a45 100644 --- a/docs/java-rest/high-level/getting-started.asciidoc +++ b/docs/java-rest/high-level/getting-started.asciidoc @@ -104,6 +104,7 @@ For Gradle: ["source","groovy",subs="attributes"] -------------------------------------------------- maven { + name 'lucene-snapshots' url 'https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/83f9835' } -------------------------------------------------- diff --git a/docs/reference/setup/setup-xclient.asciidoc b/docs/reference/setup/setup-xclient.asciidoc index 9da482af849..24cef9c7369 100644 --- a/docs/reference/setup/setup-xclient.asciidoc +++ b/docs/reference/setup/setup-xclient.asciidoc @@ -65,6 +65,7 @@ repositories { // Add the Elasticsearch Maven Repository maven { + name "elastic" url "https://artifacts.elastic.co/maven" } } diff --git a/qa/build.gradle b/qa/build.gradle index cbcb1d45807..f1727f11515 100644 --- a/qa/build.gradle +++ b/qa/build.gradle @@ -12,9 +12,11 @@ subprojects { Project subproj -> */ repositories { maven { + name "elastic" url "https://artifacts.elastic.co/maven" } maven { + name "elastic-snapshots" url "https://snapshots.elastic.co/maven" } } diff --git a/qa/wildfly/build.gradle b/qa/wildfly/build.gradle index 6ffdf24cd5d..dcbf5253bb0 100644 --- a/qa/wildfly/build.gradle +++ b/qa/wildfly/build.gradle @@ -37,6 +37,7 @@ int managementPort repositories { // the Wildfly distribution is not available via a repository, so we fake an Ivy repository on top of the download site ivy { + name "wildfly" url "https://download.jboss.org" metadataSources { artifact() diff --git a/x-pack/docs/en/watcher/java.asciidoc b/x-pack/docs/en/watcher/java.asciidoc index e5cb6b54b0c..7224196834f 100644 --- a/x-pack/docs/en/watcher/java.asciidoc +++ b/x-pack/docs/en/watcher/java.asciidoc @@ -60,6 +60,7 @@ repositories { // Add the Elasticsearch Maven Repository maven { + name "elastic" url "https://artifacts.elastic.co/maven" } } diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle index 8c17e4b1fc4..9bd4d445892 100644 --- a/x-pack/plugin/ml/build.gradle +++ b/x-pack/plugin/ml/build.gradle @@ -12,7 +12,7 @@ esplugin { repositories { ivy { - name "prelert-artifacts" + name "ml-cpp" url "https://prelert-artifacts.s3.amazonaws.com" metadataSources { // no repository metadata, look directly for the artifact diff --git a/x-pack/qa/rolling-upgrade-basic/build.gradle b/x-pack/qa/rolling-upgrade-basic/build.gradle index 4d8da870e33..8e87a1258ba 100644 --- a/x-pack/qa/rolling-upgrade-basic/build.gradle +++ b/x-pack/qa/rolling-upgrade-basic/build.gradle @@ -145,9 +145,11 @@ project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackRestSpec) repositories { maven { + name "elastic" url "https://artifacts.elastic.co/maven" } maven { + name "elastic-snapshots" url "https://snapshots.elastic.co/maven" } }