Fix eclipse issues related to rest client shading (#25874)
* A cycle was detected in eclipse, and was fixed in the same fashion as core and core-tests. * The rest client deps jar was not properly exported in the generated eclipse classpath file for rest client. Relates #25208
This commit is contained in:
parent
2c271f0f22
commit
3a20922046
|
@ -100,6 +100,18 @@ if (isIdea == false && isEclipse == false) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isEclipse) {
|
||||
// in eclipse the project is under a fake root, we need to change around the source sets
|
||||
sourceSets {
|
||||
if (project.path == ":client:rest") {
|
||||
main.java.srcDirs = ['java']
|
||||
//main.resources.srcDirs = ['resources']
|
||||
} else {
|
||||
test.java.srcDirs = ['java']
|
||||
test.resources.srcDirs = ['resources']
|
||||
}
|
||||
}
|
||||
}
|
||||
// adds a dependency to compile, so the -deps jar is built first
|
||||
sourceSets.main.output.dir(shadedSrcDir, builtBy: 'shadeDeps')
|
||||
|
||||
|
@ -113,7 +125,12 @@ dependencies {
|
|||
|
||||
compile shadeDeps.outputs.files
|
||||
|
||||
testCompile "org.elasticsearch.client:test:${version}"
|
||||
if (isEclipse == false || project.path == ":client:rest-tests") {
|
||||
testCompile("org.elasticsearch.client:test:${version}") {
|
||||
// tests use the locally compiled version of core
|
||||
exclude group: 'org.elasticsearch', module: 'elasticsearch'
|
||||
}
|
||||
}
|
||||
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
|
||||
testCompile "junit:junit:${versions.junit}"
|
||||
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
|
||||
|
@ -123,6 +140,14 @@ dependencies {
|
|||
signature "org.codehaus.mojo.signature:java17:1.0@signature"
|
||||
}
|
||||
|
||||
// Set the exported=true for the generated rest client deps since it is used by other projects in eclipse.
|
||||
// https://docs.gradle.org/3.3/userguide/eclipse_plugin.html#sec:eclipse_modify_domain_objects
|
||||
eclipse.classpath.file {
|
||||
whenMerged { classpath ->
|
||||
classpath.entries.findAll { entry -> entry.path.contains("elasticsearch-rest-client") }*.exported = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencyLicenses.dependencies = project.configurations.shade
|
||||
|
||||
forbiddenApisMain {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
// this is just shell gradle file for eclipse to have separate projects for src and tests
|
||||
apply from: '../../build.gradle'
|
|
@ -0,0 +1,6 @@
|
|||
// this is just shell gradle file for eclipse to have separate projects for src and tests
|
||||
apply from: '../../build.gradle'
|
||||
|
||||
dependencies {
|
||||
testCompile project(':client:rest')
|
||||
}
|
|
@ -96,6 +96,7 @@ if (isEclipse) {
|
|||
// eclipse cannot handle an intermediate dependency between main and test, so we must create separate projects
|
||||
// for core-src and core-tests
|
||||
projects << 'core-tests'
|
||||
projects << 'client:rest-tests'
|
||||
}
|
||||
|
||||
include projects.toArray(new String[0])
|
||||
|
@ -119,6 +120,11 @@ if (isEclipse) {
|
|||
project(":core").buildFileName = 'eclipse-build.gradle'
|
||||
project(":core-tests").projectDir = new File(rootProject.projectDir, 'core/src/test')
|
||||
project(":core-tests").buildFileName = 'eclipse-build.gradle'
|
||||
|
||||
project(":client:rest").projectDir = new File(rootProject.projectDir, 'client/rest/src/main')
|
||||
project(":client:rest").buildFileName = 'eclipse-build.gradle'
|
||||
project(":client:rest-tests").projectDir = new File(rootProject.projectDir, 'client/rest/src/test')
|
||||
project(":client:rest-tests").buildFileName = 'eclipse-build.gradle'
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue