Skip to content

Remove eclipse conditionals #44075

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 12 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
37 changes: 36 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,41 @@ allprojects {
// this is *NOT* a path or a file.
folder.output = "build-eclipse/" + i
}

// Eclipse now supports main and test source sets, but the Gradle and buildship tooling does not yet so we
// edit the generated .classpath to correctly mark test vs non test code and dependencies
// for more info: https://github.com/eclipse/buildship/issues/689 and https://github.com/gradle/gradle/issues/4802
Set<String> testOnlyProjectDependencies = new HashSet();
if (configurations.findByName("testCompile") != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be using testCompileClasspath instead of testCompile since the later is deprecated.

testOnlyProjectDependencies.addAll(
configurations.testCompile.getDependencies().findAll {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use getAllDependencies() here to ensure we also get dependencies from parent configurations (like compileOnly). Also we should stick to Groovy conventions and use property accessors allDependencies vs getter methods getAllDependencies() just for consistency. I realize this is difficult switching between Java and Groovy a lot 😄

it instanceof ProjectDependency
}.collect {
it.dependencyProject.path
}
)
}
if (configurations.findByName("compile") != null) {
testOnlyProjectDependencies.removeAll(
configurations.compile.getDependencies().findAll {
it instanceof ProjectDependency
}.collect {
it.dependencyProject.path
}
)
}
classpath.entries.each {
if (it.hasProperty("entryAttributes")) {
if (it.entryAttributes.containsKey("gradle_used_by_scope")) {
it.entryAttributes['test'] = (it.entryAttributes['gradle_used_by_scope'] == 'test')
}
if (it.hasProperty("path") && it.path.startsWith("/:")) {
if (testOnlyProjectDependencies.contains(it.path.substring(1))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we ditch the extra nested if for just another conditional?

it.entryAttributes['test'] = true
}
}
}
}
}
}

Expand Down Expand Up @@ -528,4 +563,4 @@ allprojects {
checkPart1.dependsOn check
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ eclipse.preferences.version=1
# org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
# org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning

# We check this in Gradle. Eclipse fails this check because it doesn't have separate class-paths for
org.eclipse.jdt.core.circularClasspath=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.formatter.comment.line_length=140
org.eclipse.jdt.core.formatter.lineSplit=140
Expand Down
19 changes: 2 additions & 17 deletions client/rest-high-level/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ dependencies {
testCompile project(":rest-api-spec")
// Needed for serialization tests:
// (In order to serialize a server side class to a client side class or the other way around)
if (isEclipse == false || project.path == ":client:rest-high-level-tests") {
testCompile(project(':x-pack:plugin:core')) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-rest-high-level-client'
}
testCompile(project(':x-pack:plugin:core')) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-rest-high-level-client'
}

restSpec project(':rest-api-spec')
Expand Down Expand Up @@ -100,19 +98,6 @@ forbiddenApisMain {
signaturesFiles += files('src/main/resources/forbidden/rest-high-level-signatures.txt')
}

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-high-level") {
main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources']
} else {
test.java.srcDirs = ['java']
test.resources.srcDirs = ['resources']
}
}
}

File nodeCert = file("./testnode.crt")
File nodeTrustStore = file("./testnode.jks")

Expand Down
2 changes: 0 additions & 2 deletions client/rest-high-level/src/main/eclipse-build.gradle

This file was deleted.

6 changes: 0 additions & 6 deletions client/rest-high-level/src/test/eclipse-build.gradle

This file was deleted.

1 change: 0 additions & 1 deletion libs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ subprojects {
Project depProject = dep.dependencyProject
if (depProject != null
&& false == depProject.path.equals(':libs:elasticsearch-core')
&& false == isEclipse
&& depProject.path.startsWith(':libs')) {
throw new InvalidUserDataException("projects in :libs "
+ "may not depend on other projects libs except "
Expand Down
340 changes: 340 additions & 0 deletions libs/core/.classpath1

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions libs/core/.project1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this was mistakenly checked in.

<projectDescription>
<name>:libs:elasticsearch-core</name>
<comment>Elasticsearch subproject :libs:elasticsearch-core</comment>
<projects/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments/>
</buildCommand>
</buildSpec>
<linkedResources/>
<filteredResources/>
</projectDescription>
19 changes: 2 additions & 17 deletions libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ dependencies {
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"

if (isEclipse == false || project.path == ":libs:elasticsearch-core-tests") {
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-core'
}
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-core'
}
}

Expand All @@ -39,19 +37,6 @@ forbiddenApisMain {
replaceSignatureFiles 'jdk-signatures'
}

if (isEclipse) {
// in eclipse the project is under a fake root, we need to change around the source sets
sourceSets {
if (project.path == ":libs:elasticsearch-core") {
main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources']
} else {
test.java.srcDirs = ['java']
test.resources.srcDirs = ['resources']
}
}
}

thirdPartyAudit.ignoreMissingClasses (
// from log4j
'org/osgi/framework/AdaptPermission',
Expand Down
2 changes: 0 additions & 2 deletions libs/core/src/main/eclipse-build.gradle

This file was deleted.

6 changes: 0 additions & 6 deletions libs/core/src/test/eclipse-build.gradle

This file was deleted.

18 changes: 2 additions & 16 deletions libs/dissect/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
*/

dependencies {
if (isEclipse == false || project.path == ":libs:elasticsearch-dissect-tests") {
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-dissect'
}
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-dissect'
}
testCompile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
testCompile "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
Expand All @@ -32,15 +30,3 @@ forbiddenApisMain {
replaceSignatureFiles 'jdk-signatures'
}

if (isEclipse) {
// in eclipse the project is under a fake root, we need to change around the source sets
sourceSets {
if (project.path == ":libs:elasticsearch-dissect") {
main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources']
} else {
test.java.srcDirs = ['java']
test.resources.srcDirs = ['resources']
}
}
}
3 changes: 0 additions & 3 deletions libs/dissect/src/main/eclipse-build.gradle

This file was deleted.

7 changes: 0 additions & 7 deletions libs/dissect/src/test/eclipse-build.gradle

This file was deleted.

18 changes: 2 additions & 16 deletions libs/geo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ apply plugin: 'nebula.maven-base-publish'
apply plugin: 'nebula.maven-scm'

dependencies {
if (isEclipse == false || project.path == ":libs:elasticsearch-geo-tests") {
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-geo'
}
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-geo'
}
}

Expand All @@ -35,15 +33,3 @@ forbiddenApisMain {
replaceSignatureFiles 'jdk-signatures'
}

if (isEclipse) {
// in eclipse the project is under a fake root, we need to change around the source sets
sourceSets {
if (project.path == ":libs:elasticsearch-geo") {
main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources']
} else {
test.java.srcDirs = ['java']
test.resources.srcDirs = ['resources']
}
}
}
3 changes: 0 additions & 3 deletions libs/geo/src/main/eclipse-build.gradle

This file was deleted.

6 changes: 0 additions & 6 deletions libs/geo/src/test/eclipse-build.gradle

This file was deleted.

19 changes: 2 additions & 17 deletions libs/grok/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,15 @@ dependencies {
// joni dependencies:
compile 'org.jruby.jcodings:jcodings:1.0.44'

if (isEclipse == false || project.path == ":libs:elasticsearch-grok-tests") {
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-grok'
}
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-grok'
}
}

forbiddenApisMain {
replaceSignatureFiles 'jdk-signatures'
}

if (isEclipse) {
// in eclipse the project is under a fake root, we need to change around the source sets
sourceSets {
if (project.path == ":libs:elasticsearch-grok") {
main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources']
} else {
test.java.srcDirs = ['java']
test.resources.srcDirs = ['resources']
}
}
}

thirdPartyAudit.ignoreMissingClasses (
// joni has AsmCompilerSupport, but that isn't being used:
'org.objectweb.asm.ClassWriter',
Expand Down
3 changes: 0 additions & 3 deletions libs/grok/src/main/eclipse-build.gradle

This file was deleted.

7 changes: 0 additions & 7 deletions libs/grok/src/test/eclipse-build.gradle

This file was deleted.

18 changes: 2 additions & 16 deletions libs/nio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,11 @@ dependencies {
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"

if (isEclipse == false || project.path == ":libs:elasticsearch-nio-tests") {
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-nio'
}
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-nio'
}
}

if (isEclipse) {
// in eclipse the project is under a fake root, we need to change around the source sets
sourceSets {
if (project.path == ":libs:elasticsearch-nio") {
main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources']
} else {
test.java.srcDirs = ['java']
test.resources.srcDirs = ['resources']
}
}
}

forbiddenApisMain {
// nio does not depend on core, so only jdk signatures should be checked
Expand Down
3 changes: 0 additions & 3 deletions libs/nio/src/main/eclipse-build.gradle

This file was deleted.

7 changes: 0 additions & 7 deletions libs/nio/src/test/eclipse-build.gradle

This file was deleted.

21 changes: 3 additions & 18 deletions libs/secure-sm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,16 @@ dependencies {
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest:${versions.hamcrest}"

if (isEclipse == false || project.path == ":libs:elasticsearch-secure-sm-tests") {
testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-secure-sm'
}

testCompile(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-secure-sm'
}
}

forbiddenApisMain {
replaceSignatureFiles 'jdk-signatures'
}

if (isEclipse) {
// in Eclipse the project is under a fake root so we need to change around the source sets
sourceSets {
if (project.path == ":libs:elasticsearch-secure-sm") {
main.java.srcDirs = ['java']
main.resources.srcDirs = ['resources']
} else {
test.java.srcDirs = ['java']
test.resources.srcDirs = ['resources']
}
}
}

// JAR hell is part of core which we do not want to add as a dependency
jarHell.enabled = false

Expand Down
3 changes: 0 additions & 3 deletions libs/secure-sm/src/main/eclipse-build.gradle

This file was deleted.

7 changes: 0 additions & 7 deletions libs/secure-sm/src/test/eclipse-build.gradle

This file was deleted.

Loading