From 5540af5941b6b293942a827f15359c541e9a4ba1 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 10 Jul 2018 09:47:06 +0300 Subject: [PATCH 1/3] Detect and prevent configuration that triggers a Gradle bug As we found in #31862, this can lead to a lot of wasted time as it's not immediatly obvius what's going on. Givent how many projects we have it's getting increasingly easier to run into gradle/gradle#847. --- build.gradle | 18 +++++++++++++++++- client/test/build.gradle | 2 ++ libs/cli/build.gradle | 10 ---------- plugins/discovery-ec2/qa/build.gradle | 1 + plugins/repository-azure/qa/build.gradle | 1 + plugins/repository-gcs/qa/build.gradle | 1 + settings.gradle | 2 ++ .../with-system-key/build.gradle | 1 + .../without-system-key/build.gradle | 1 + x-pack/qa/sql/security/build.gradle | 2 ++ 10 files changed, 28 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 0d77f8fd59ef0..08ba524249915 100644 --- a/build.gradle +++ b/build.gradle @@ -222,7 +222,7 @@ subprojects { "org.elasticsearch.gradle:build-tools:${version}": ':build-tools', "org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec', "org.elasticsearch:elasticsearch:${version}": ':server', - "org.elasticsearch:elasticsearch-cli:${version}": ':libs:cli', + "org.elasticsearch:elasticsearch-cli:${version}": ':libs:elasticsearch-cli', "org.elasticsearch:elasticsearch-core:${version}": ':libs:core', "org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio', "org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content', @@ -579,6 +579,22 @@ gradle.projectsEvaluated { } } } + project.allprojects.forEach { outer -> + project.allprojects.forEach { inner -> + if (inner.path == outer.path) { + // same project, do nothing + return + } + if (inner.name == outer.name && inner.group == outer.group) { + throw new GradleException( + "Detected that two projects: ${inner.path} and ${outer.path} " + + "have the same name and group: ${inner.group}:${inner.name}. " + + "This doesn't currently work correctly in Gradle, see: " + + "https://github.com/gradle/gradle/issues/847" + ) + } + } + } } if (System.properties.get("build.compare") != null) { diff --git a/client/test/build.gradle b/client/test/build.gradle index 59c45186fe76b..cc69a1828dc85 100644 --- a/client/test/build.gradle +++ b/client/test/build.gradle @@ -25,6 +25,8 @@ apply plugin: 'elasticsearch.build' targetCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_7 +group = "${group}.client.test" + dependencies { compile "org.apache.httpcomponents:httpcore:${versions.httpcore}" compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" diff --git a/libs/cli/build.gradle b/libs/cli/build.gradle index 91fbca19eca99..00d6d96ef0d59 100644 --- a/libs/cli/build.gradle +++ b/libs/cli/build.gradle @@ -24,16 +24,6 @@ apply plugin: 'nebula.optional-base' apply plugin: 'nebula.maven-base-publish' apply plugin: 'nebula.maven-scm' -publishing { - publications { - nebula { - artifactId 'elasticsearch-cli' - } - } -} - -archivesBaseName = 'elasticsearch-cli' - dependencies { compile 'net.sf.jopt-simple:jopt-simple:5.0.2' compile "org.elasticsearch:elasticsearch-core:${version}" diff --git a/plugins/discovery-ec2/qa/build.gradle b/plugins/discovery-ec2/qa/build.gradle index e69de29bb2d1d..0aed6df883825 100644 --- a/plugins/discovery-ec2/qa/build.gradle +++ b/plugins/discovery-ec2/qa/build.gradle @@ -0,0 +1 @@ +group = "${group}.plugins.discovery-ec2.qa" diff --git a/plugins/repository-azure/qa/build.gradle b/plugins/repository-azure/qa/build.gradle index e69de29bb2d1d..5c25485a8f596 100644 --- a/plugins/repository-azure/qa/build.gradle +++ b/plugins/repository-azure/qa/build.gradle @@ -0,0 +1 @@ +group = "${group}.plugins.repository-azure.qa" diff --git a/plugins/repository-gcs/qa/build.gradle b/plugins/repository-gcs/qa/build.gradle index e69de29bb2d1d..d10d9050dfecf 100644 --- a/plugins/repository-gcs/qa/build.gradle +++ b/plugins/repository-gcs/qa/build.gradle @@ -0,0 +1 @@ +group = "${group}.plugins.repository-gcs.qa" diff --git a/settings.gradle b/settings.gradle index 5904cc4daf4d5..bdd866e622bcd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -131,3 +131,5 @@ if (extraProjects.exists()) { // enable in preparation for Gradle 5.0 enableFeaturePreview('STABLE_PUBLISHING') + +project(":libs:cli").name = 'elasticsearch-cli' diff --git a/x-pack/qa/rolling-upgrade/with-system-key/build.gradle b/x-pack/qa/rolling-upgrade/with-system-key/build.gradle index e69de29bb2d1d..03505e01dedd8 100644 --- a/x-pack/qa/rolling-upgrade/with-system-key/build.gradle +++ b/x-pack/qa/rolling-upgrade/with-system-key/build.gradle @@ -0,0 +1 @@ +group = "${group}.x-pack.qa.rolling-upgrade.with-system-key" diff --git a/x-pack/qa/rolling-upgrade/without-system-key/build.gradle b/x-pack/qa/rolling-upgrade/without-system-key/build.gradle index e69de29bb2d1d..aa7ac502eb3e6 100644 --- a/x-pack/qa/rolling-upgrade/without-system-key/build.gradle +++ b/x-pack/qa/rolling-upgrade/without-system-key/build.gradle @@ -0,0 +1 @@ +group = "${group}.x-pack.qa.rolling-upgrade.without-system-key" diff --git a/x-pack/qa/sql/security/build.gradle b/x-pack/qa/sql/security/build.gradle index 5c3169d9d20dc..15f7734f9422e 100644 --- a/x-pack/qa/sql/security/build.gradle +++ b/x-pack/qa/sql/security/build.gradle @@ -4,6 +4,8 @@ dependencies { Project mainProject = project +group = "${group}.x-pack.qa.sql.security" + subprojects { // Use resources from the parent project in subprojects sourceSets { From 4e7dfd66fdec61a84a7cad4aaa3d62352d78582f Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 17 Jul 2018 14:40:02 +0300 Subject: [PATCH 2/3] PR review --- build.gradle | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 08ba524249915..d88d3ae54275a 100644 --- a/build.gradle +++ b/build.gradle @@ -579,20 +579,19 @@ gradle.projectsEvaluated { } } } - project.allprojects.forEach { outer -> - project.allprojects.forEach { inner -> - if (inner.path == outer.path) { - // same project, do nothing - return - } - if (inner.name == outer.name && inner.group == outer.group) { - throw new GradleException( - "Detected that two projects: ${inner.path} and ${outer.path} " + - "have the same name and group: ${inner.group}:${inner.name}. " + - "This doesn't currently work correctly in Gradle, see: " + - "https://github.com/gradle/gradle/issues/847" - ) - } + // Having the same group and name for distinct projects causes Gradle to consider them equal when resolving + // dependencies leading to hard to debug failures. Run a check across all project and prevent this from happening. + // see: https://github.com/gradle/gradle/issues/847 + Map coordsToProject = [:] + project.allprojects.forEach { p -> + String coords = "${p.group}:${p.name}" + if (false == coordsToProject.putIfAbsent(coords, p)) { + throw new GradleException( + "Detected that two projects: ${p.path} and ${coordsToProject[coords].path} " + + "have the same name and group: ${coords}. " + + "This doesn't currently work correctly in Gradle, see: " + + "https://github.com/gradle/gradle/issues/847" + ) } } } From 39d1034f39afaac5581093de72290d6369e3c86f Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Wed, 18 Jul 2018 10:02:51 +0300 Subject: [PATCH 3/3] PR review --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0a9cdc1651c90..66f34d8f445de 100644 --- a/build.gradle +++ b/build.gradle @@ -623,7 +623,7 @@ gradle.projectsEvaluated { } } // Having the same group and name for distinct projects causes Gradle to consider them equal when resolving - // dependencies leading to hard to debug failures. Run a check across all project and prevent this from happening. + // dependencies leading to hard to debug failures. Run a check across all project to prevent this from happening. // see: https://github.com/gradle/gradle/issues/847 Map coordsToProject = [:] project.allprojects.forEach { p ->