Skip to content

Commit edd9597

Browse files
committed
Revert "Fix eclipse for build tools (#73699) (7.x backport) (#73904)"
This reverts commit 3799abc
1 parent c947114 commit edd9597

File tree

5 files changed

+64
-182
lines changed

5 files changed

+64
-182
lines changed

build-conventions/build.gradle

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66
* Side Public License, v 1.
77
*/
88

9-
import org.gradle.plugins.ide.eclipse.model.SourceFolder;
10-
119
plugins {
1210
id 'java-gradle-plugin'
1311
id 'java-test-fixtures'
14-
id 'eclipse'
1512
}
1613

1714
group = "org.elasticsearch"
@@ -28,10 +25,6 @@ gradlePlugin {
2825
id = 'elasticsearch.internal-licenseheaders'
2926
implementationClass = 'org.elasticsearch.gradle.internal.conventions.precommit.LicenseHeadersPrecommitPlugin'
3027
}
31-
eclipse {
32-
id = 'elasticsearch.eclipse'
33-
implementationClass = 'org.elasticsearch.gradle.internal.conventions.EclipseConventionPlugin'
34-
}
3528
publish {
3629
id = 'elasticsearch.publish'
3730
implementationClass = 'org.elasticsearch.gradle.internal.conventions.PublishPlugin'
@@ -57,19 +50,3 @@ dependencies {
5750
api 'gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0'
5851
api 'org.apache.rat:apache-rat:0.11'
5952
}
60-
61-
project.getPlugins().withType(JavaBasePlugin.class, javaBasePlugin -> {
62-
java.getModularity().getInferModulePath().set(false);
63-
eclipse.getClasspath().getFile().whenMerged { classpath ->
64-
/*
65-
* give each source folder a unique corresponding output folder
66-
* outside of the usual `build` folder. We can't put the build
67-
* in the usual build folder because eclipse becomes *very* sad
68-
* if we delete it. Which `gradlew clean` does all the time.
69-
*/
70-
int i = 0;
71-
classpath.getEntries().stream().filter(e -> e instanceof SourceFolder).forEachOrdered(s ->
72-
s.setOutput("out/eclipse"+i++)
73-
)
74-
}
75-
})

build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/EclipseConventionPlugin.java

Lines changed: 0 additions & 138 deletions
This file was deleted.

build-tools-internal/build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,13 @@
99
import org.gradle.internal.jvm.Jvm
1010
import org.gradle.util.GradleVersion
1111
import org.elasticsearch.gradle.internal.conventions.VersionPropertiesLoader
12-
import org.apache.tools.ant.taskdefs.condition.Os
13-
import org.gradle.plugins.ide.eclipse.model.AccessRule
14-
import org.gradle.plugins.ide.eclipse.model.SourceFolder
15-
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
1612

1713
plugins {
1814
id 'java-gradle-plugin'
1915
id 'groovy-gradle-plugin'
2016
id 'groovy'
2117
id 'elasticsearch.internal-licenseheaders'
2218
id 'elasticsearch.basic-build-tool-conventions'
23-
id 'elasticsearch.eclipse'
2419
}
2520

2621
group = 'org.elasticsearch.gradle'

build-tools/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ description = "The elasticsearch build tools"
2222
// we write this back out below to load it in the Build.java which will be shown in rest main action
2323
// to indicate this being a snapshot build or a release build.
2424
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('../build-tools-internal/version.properties'))
25-
2625
allprojects {
2726
group = "org.elasticsearch"
2827
version = props.getProperty("elasticsearch")
2928

3029
apply plugin: 'java'
31-
apply plugin: 'elasticsearch.eclipse'
3230
targetCompatibility = 11
3331
sourceCompatibility = 11
3432
}
@@ -219,4 +217,4 @@ tasks.named("check").configure { dependsOn("integTest") }
219217
// baseClass 'spock.lang.Specification'
220218
// }
221219
// }
222-
// }
220+
// }

build.gradle

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,42 @@ gradle.projectsEvaluated {
314314

315315
// eclipse configuration
316316
allprojects {
317-
apply plugin: 'elasticsearch.eclipse'
317+
apply plugin: 'eclipse'
318+
// Name all the non-root projects after their path so that paths get grouped together when imported into eclipse.
319+
if (path != ':') {
320+
eclipse.project.name = path
321+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
322+
eclipse.project.name = eclipse.project.name.replace(':', '_')
323+
}
324+
}
325+
326+
plugins.withType(JavaBasePlugin) {
327+
java.modularity.inferModulePath.set(false)
328+
eclipse.classpath.file.whenMerged { classpath ->
329+
/*
330+
* give each source folder a unique corresponding output folder
331+
* outside of the usual `build` folder. We can't put the build
332+
* in the usual build folder because eclipse becomes *very* sad
333+
* if we delete it. Which `gradlew clean` does all the time.
334+
*/
335+
int i = 0;
336+
classpath.entries.findAll { it instanceof SourceFolder }.each { folder ->
337+
i++;
338+
folder.output = 'out/eclipse/' + i
339+
}
318340

341+
// Starting with Gradle 6.7 test dependencies are not exposed by eclipse
342+
// projects by default. This breaks project dependencies using the `java-test-fixtures` plugin
343+
// or dependencies on other projects manually declared testArtifacts configurations
344+
// This issue is tracked in gradle issue tracker.
345+
// See https://github.com/gradle/gradle/issues/14932 for further details
346+
classpath.entries.findAll {
347+
it instanceof ProjectDependency
348+
}.each {
349+
it.entryAttributes.remove('without_test_code')
350+
}
351+
}
352+
}
319353
/*
320354
* Allow accessing com/sun/net/httpserver in projects that have
321355
* configured forbidden apis to allow it.
@@ -331,6 +365,34 @@ allprojects {
331365
}
332366
}
333367
}
368+
369+
File licenseHeaderFile
370+
String prefix = ':x-pack'
371+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
372+
prefix = prefix.replace(':', '_')
373+
}
374+
if (eclipse.project.name.startsWith(prefix)) {
375+
licenseHeaderFile = new File(project.rootDir, 'build-tools-internal/src/main/resources/license-headers/elastic-license-2.0-header.txt')
376+
} else {
377+
licenseHeaderFile = new File(project.rootDir, 'build-tools-internal/src/main/resources/license-headers/sspl+elastic-license-header.txt')
378+
}
379+
380+
String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n'
381+
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator)
382+
tasks.register('copyEclipseSettings', Copy) {
383+
mustRunAfter 'wipeEclipseSettings'
384+
// TODO: "package this up" for external builds
385+
from new File(project.rootDir, 'build-tools-internal/src/main/resources/eclipse.settings')
386+
into '.settings'
387+
filter { it.replaceAll('@@LICENSE_HEADER_TEXT@@', licenseHeader) }
388+
}
389+
// otherwise .settings is not nuked entirely
390+
tasks.register('wipeEclipseSettings', Delete) {
391+
delete '.settings'
392+
}
393+
tasks.named('cleanEclipse') { dependsOn 'wipeEclipseSettings' }
394+
// otherwise the eclipse merging is *super confusing*
395+
tasks.named('eclipse') { dependsOn 'cleanEclipse', 'copyEclipseSettings' }
334396
}
335397

336398
tasks.named("wrapper").configure {
@@ -439,18 +501,6 @@ tasks.named("assemble").configure {
439501
dependsOn gradle.includedBuild('build-tools').task(':assemble')
440502
}
441503

442-
tasks.named("cleanEclipse").configure {
443-
dependsOn gradle.includedBuild('build-conventions').task(':cleanEclipse')
444-
dependsOn gradle.includedBuild('build-tools').task(':cleanEclipse')
445-
dependsOn gradle.includedBuild('build-tools-internal').task(':cleanEclipse')
446-
}
447-
448-
tasks.named("eclipse").configure {
449-
dependsOn gradle.includedBuild('build-conventions').task(':eclipse')
450-
dependsOn gradle.includedBuild('build-tools').task(':eclipse')
451-
dependsOn gradle.includedBuild('build-tools-internal').task(':eclipse')
452-
}
453-
454504
subprojects {
455505
project.ext.disableTasks = { String... tasknames ->
456506
for (String taskname : tasknames) {

0 commit comments

Comments
 (0)