Skip to content

Detect and prevent configuration that triggers a Gradle bug #31912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -579,6 +579,21 @@ 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: project and -> projects to

// 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"
)
}
}
}

if (System.properties.get("build.compare") != null) {
Expand Down
2 changes: 2 additions & 0 deletions client/test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
10 changes: 0 additions & 10 deletions libs/cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions plugins/discovery-ec2/qa/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
group = "${group}.plugins.discovery-ec2.qa"
1 change: 1 addition & 0 deletions plugins/repository-azure/qa/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
group = "${group}.plugins.repository-azure.qa"
1 change: 1 addition & 0 deletions plugins/repository-gcs/qa/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
group = "${group}.plugins.repository-gcs.qa"
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ if (extraProjects.exists()) {

// enable in preparation for Gradle 5.0
enableFeaturePreview('STABLE_PUBLISHING')

project(":libs:cli").name = 'elasticsearch-cli'
1 change: 1 addition & 0 deletions x-pack/qa/rolling-upgrade/with-system-key/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
group = "${group}.x-pack.qa.rolling-upgrade.with-system-key"
1 change: 1 addition & 0 deletions x-pack/qa/rolling-upgrade/without-system-key/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
group = "${group}.x-pack.qa.rolling-upgrade.without-system-key"
2 changes: 2 additions & 0 deletions x-pack/qa/sql/security/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down