Skip to content

Commit aa8f97d

Browse files
committed
GH-11819: Fix the Eclipse part to support deveopment of the MR-JAR: (#11823)
- by default, Lucene will only generate a config for Java 17 (or 11 in 9.x), without the MR-JAR sourceSets - if passed -Peclipse.javaVersion=19, it will include matching sourcesets and set compiler version to given version in classpath
1 parent 35bd42f commit aa8f97d

File tree

2 files changed

+17
-94
lines changed

2 files changed

+17
-94
lines changed

gradle/ide/eclipse.gradle

+17-7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def resources = scriptResources(buildscript)
2424
configure(rootProject) {
2525
apply plugin: "eclipse"
2626

27+
def eclipseJavaVersion = propertyOrDefault("eclipse.javaVersion", rootProject.minJavaVersion)
2728
def relativize = { other -> rootProject.rootDir.relativePath(other).toString() }
2829

2930
eclipse {
@@ -41,13 +42,16 @@ configure(rootProject) {
4142
def projects = allprojects.findAll { prj ->
4243
return prj.plugins.hasPlugin(JavaPlugin)
4344
}
44-
45+
46+
Set<String> sourceSetNames = ["main", "test", "main${eclipseJavaVersion}", "test${eclipseJavaVersion}", "tools"] as Set
4547
Set<String> sources = []
4648
Set<File> jars = []
4749
projects.each { prj ->
4850
prj.sourceSets.each { sourceSet ->
49-
sources += sourceSet.java.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
50-
sources += sourceSet.resources.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
51+
if (sourceSetNames.contains(sourceSet.name)) {
52+
sources += sourceSet.java.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
53+
sources += sourceSet.resources.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
54+
}
5155
}
5256

5357
// This is hacky - we take the resolved compile classpath and just
@@ -71,9 +75,9 @@ configure(rootProject) {
7175
}
7276

7377
jdt {
74-
sourceCompatibility = rootProject.minJavaVersion
75-
targetCompatibility = rootProject.minJavaVersion
76-
javaRuntimeName = "JavaSE-${rootProject.minJavaVersion}"
78+
sourceCompatibility = eclipseJavaVersion
79+
targetCompatibility = eclipseJavaVersion
80+
javaRuntimeName = "JavaSE-$eclipseJavaVersion"
7781
}
7882
}
7983

@@ -85,6 +89,7 @@ configure(rootProject) {
8589

8690
inputs.file(ecjLintFile)
8791
inputs.property('errorMode', errorMode)
92+
inputs.property('eclipseJavaVersion', eclipseJavaVersion as String)
8893

8994
from rootProject.file("${resources}/dot.settings")
9095
into rootProject.file(".settings")
@@ -94,14 +99,19 @@ configure(rootProject) {
9499
filteringCharset = 'UTF-8'
95100

96101
doLast {
97-
logger.lifecycle('Eclipse config written with ECJ errors configured as {}. Change by passing -Peclipse.errors=ignore/warning/error.', errorMode)
102+
logger.lifecycle('Eclipse config for Java {} written with ECJ errors configured as {}. Change by passing -Peclipse.errors=ignore/warning/error.', eclipseJavaVersion, errorMode)
103+
logger.lifecycle('To edit classes of MR-JARs for a specific Java version, use e.g., -Peclipse.javaVersion=19')
98104
}
99105
}
100106

101107
eclipseJdt {
102108
enabled = false
103109
dependsOn 'luceneEclipseJdt'
104110
}
111+
112+
eclipseClasspath {
113+
inputs.property('eclipseJavaVersion', eclipseJavaVersion as String)
114+
}
105115
}
106116

107117
public class LibEntry implements ClasspathEntry {

gradle/ide/eclipse/dot.classpath.xsl

-87
This file was deleted.

0 commit comments

Comments
 (0)