Detect and prevent configuration that triggers a Gradle bug (#31912)

* 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.
This commit is contained in:
Alpar Torok 2018-07-19 06:46:58 +00:00 committed by GitHub
parent aae0133847
commit 38e2e1d553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 27 additions and 11 deletions

View File

@ -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',
@ -622,6 +622,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 to 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"
)
}
}
}
if (System.properties.get("build.compare") != null) {

View File

@ -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}"

View File

@ -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}"

View File

@ -0,0 +1 @@
group = "${group}.plugins.discovery-ec2.qa"

View File

@ -0,0 +1 @@
group = "${group}.plugins.repository-azure.qa"

View File

@ -0,0 +1 @@
group = "${group}.plugins.repository-gcs.qa"

View File

@ -131,3 +131,5 @@ if (extraProjects.exists()) {
// enable in preparation for Gradle 5.0
enableFeaturePreview('STABLE_PUBLISHING')
project(":libs:cli").name = 'elasticsearch-cli'

View File

@ -0,0 +1 @@
group = "${group}.x-pack.qa.rolling-upgrade.with-system-key"

View File

@ -0,0 +1 @@
group = "${group}.x-pack.qa.rolling-upgrade.without-system-key"

View File

@ -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 {