Skip to content

Commit 0a14bb1

Browse files
committed
Remove eclipse conditionals (#44075)
* Remove eclipse conditionals We used to have some meta projects with a `-test` prefix because historically eclipse could not distinguish between test and main source-sets and could only use a single classpath. This is no longer the case for the past few Eclipse versions. This PR adds the necessary configuration to correctly categorize source folders and libraries. With this change eclipse can import projects, and the visibility rules are correct e.x. auto compete doesn't offer classes from test code or `testCompile` dependencies when editing classes in `main`. Unfortunately the cyclic dependency detection in Eclipse doesn't seem to take the difference between test and non test source sets into account, but since we are checking this in Gradle anyhow, it's safe to set to `warning` in the settings. Unfortunately there is no setting to ignore it. This might cause problems when building since Eclipse will probably not know the right order to build things in so more wirk might be necesarry.
1 parent d55378e commit 0a14bb1

File tree

45 files changed

+403
-367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+403
-367
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,16 @@ and `JAVA11_HOME` available so that the tests can pass.
109109
Elasticsearch uses the Gradle wrapper for its build. You can execute Gradle
110110
using the wrapper via the `gradlew` script in the root of the repository.
111111

112-
We support development in the Eclipse and IntelliJ IDEs. For Eclipse, the
113-
minimum version that we support is [Eclipse Oxygen][eclipse] (version 4.7). For
114-
IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij].
112+
We support development in the Eclipse and IntelliJ IDEs.
113+
For Eclipse, the minimum version that we support is [4.13][eclipse].
114+
For IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij].
115115

116116
### Configuring IDEs And Running Tests
117117

118118
Eclipse users can automatically configure their IDE: `./gradlew eclipse`
119-
then `File: Import: Existing Projects into Workspace`. Select the
120-
option `Search for nested projects`. Additionally you will want to
121-
ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini`
122-
accordingly to avoid GC overhead errors.
119+
then `File: Import: Gradle : Existing Gradle Project`.
120+
Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying
121+
`eclipse.ini` accordingly to avoid GC overhead and OOM errors.
123122

124123
IntelliJ users can automatically configure their IDE: `./gradlew idea`
125124
then `File->New Project From Existing Sources`. Point to the root of
@@ -438,6 +437,6 @@ Finally, we require that you run `./gradlew check` before submitting a
438437
non-documentation contribution. This is mentioned above, but it is worth
439438
repeating in this section because it has come up in this context.
440439

441-
[eclipse]: http://www.eclipse.org/community/eclipse_newsletter/2017/june/
440+
[eclipse]: https://download.eclipse.org/eclipse/downloads/drops4/R-4.13-201909161045/
442441
[intellij]: https://blog.jetbrains.com/idea/2017/07/intellij-idea-2017-2-is-here-smart-sleek-and-snappy/
443442
[shadow-plugin]: https://github.com/johnrengelman/shadow

build.gradle

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -384,29 +384,19 @@ allprojects {
384384
}
385385

386386
plugins.withType(JavaBasePlugin) {
387-
File eclipseBuild = project.file('build-eclipse')
388-
eclipse.classpath.defaultOutputDir = eclipseBuild
389-
if (isEclipse) {
390-
// set this so generated dirs will be relative to eclipse build
391-
project.buildDir = eclipseBuild
392-
// Work around https://docs.gradle.org/current/userguide/java_gradle_plugin.html confusing Eclipse by the metadata
393-
// it adds to the classpath
394-
project.file("$buildDir/pluginUnderTestMetadata").mkdirs()
395-
}
387+
eclipse.classpath.defaultOutputDir = file('build-eclipse')
396388
eclipse.classpath.file.whenMerged { classpath ->
397389
// give each source folder a unique corresponding output folder
398390
int i = 0;
399391
classpath.entries.findAll { it instanceof SourceFolder }.each { folder ->
400392
i++;
401-
// this is *NOT* a path or a file.
402393
folder.output = "build-eclipse/" + i
403394
}
404395
}
405396
}
406397

407-
File licenseHeaderFile;
408-
String prefix = ':x-pack';
409-
398+
File licenseHeaderFile
399+
String prefix = ':x-pack'
410400
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
411401
prefix = prefix.replace(':', '_')
412402
}

buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ eclipse.preferences.version=1
1515
# org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
1616
# org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
1717

18+
# We check this in Gradle. Eclipse fails this check because it doesn't have separate class-paths for
19+
org.eclipse.jdt.core.circularClasspath=warning
1820
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
1921
org.eclipse.jdt.core.formatter.comment.line_length=140
2022
org.eclipse.jdt.core.formatter.lineSplit=140

client/rest-high-level/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ dependencies {
6767
testCompile project(":rest-api-spec")
6868
// Needed for serialization tests:
6969
// (In order to serialize a server side class to a client side class or the other way around)
70-
testCompile project(':x-pack:plugin:core')
70+
testCompile(project(':x-pack:plugin:core')) {
71+
exclude group: 'org.elasticsearch', module: 'elasticsearch-rest-high-level-client'
72+
}
7173

7274
restSpec project(':rest-api-spec')
7375
}
@@ -95,6 +97,7 @@ forbiddenApisMain {
9597
addSignatureFiles 'http-signatures'
9698
signaturesFiles += files('src/main/resources/forbidden/rest-high-level-signatures.txt')
9799
}
100+
98101
File nodeCert = file("./testnode.crt")
99102
File nodeTrustStore = file("./testnode.jks")
100103
File pkiTrustCert = file("./src/test/resources/org/elasticsearch/client/security/delegate_pki/testRootCA.crt")

libs/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ subprojects {
3434
Project depProject = dep.dependencyProject
3535
if (depProject != null
3636
&& false == depProject.path.equals(':libs:elasticsearch-core')
37-
&& false == isEclipse
3837
&& depProject.path.startsWith(':libs')) {
3938
throw new InvalidUserDataException("projects in :libs "
4039
+ "may not depend on other projects libs except "

0 commit comments

Comments
 (0)