Skip to content

Commit f4339ee

Browse files
authored
An attempt to use gradle's eclipse plugin to provide us with src paths for libs (#14870)
1 parent 72da91f commit f4339ee

File tree

2 files changed

+20
-35
lines changed

2 files changed

+20
-35
lines changed

build-tools/build-infra/src/main/groovy/lucene.ide.eclipse.gradle

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,28 @@ if (gradle.startParameter.taskNames.contains("eclipse")) {
4242
classpath {
4343
defaultOutputDir = file('build/eclipse')
4444

45+
downloadSources = true
46+
downloadJavadoc = false
47+
48+
plusConfigurations += allprojects.findAll{ prj ->
49+
return prj.plugins.hasPlugin(JavaPlugin)
50+
}.collectMany {
51+
return [ it.configurations.compileClasspath, it.configurations.testCompileClasspath ]
52+
}
53+
4554
file {
46-
beforeMerged { classpath ->
55+
whenMerged { classpath ->
4756
classpath.entries.removeAll {
48-
it.kind == "src"
57+
return it.kind == "src" || (it.kind == "lib" && it.getPath() ==~ /(.+)lucene-.*\.jar/)
58+
}
59+
60+
// I'm not sure what these attributes are supposed to do. Keeping the previous version of having no-attributes.
61+
classpath.entries.each {
62+
if (it.kind == "lib") {
63+
it.getEntryAttributes().clear()
64+
}
4965
}
50-
}
5166

52-
whenMerged { classpath ->
5367
def projects = allprojects.findAll { prj ->
5468
return prj.plugins.hasPlugin(JavaPlugin)
5569
}
@@ -62,31 +76,20 @@ if (gradle.startParameter.taskNames.contains("eclipse")) {
6276
'tools'
6377
] as Set
6478
Set<String> sources = []
65-
Set<File> jars = []
6679
projects.each { prj ->
6780
prj.sourceSets.each { sourceSet ->
6881
if (sourceSetNames.contains(sourceSet.name)) {
6982
sources += sourceSet.java.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
7083
sources += sourceSet.resources.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
7184
}
7285
}
73-
74-
// This is hacky - we take the resolved compile classpath and just
75-
// include JAR files from there. We should probably make it smarter
76-
// by looking at real dependencies. But then: this Eclipse configuration
77-
// doesn't really separate sources anyway so why bother.
78-
jars += prj.configurations.compileClasspath.resolve()
79-
jars += prj.configurations.testCompileClasspath.resolve()
8086
}
8187

8288
classpath.entries += sources.sort().collect { name ->
8389
def sourceFolder = new SourceFolder(name, "build/eclipse/" + name)
8490
sourceFolder.setExcludes(["module-info.java"])
8591
return sourceFolder
8692
}
87-
classpath.entries += jars.unique().findAll { location -> location.isFile() && !(location.name ==~ /lucene-.*\.jar/) }.collect { location ->
88-
new LibEntry(location.toString())
89-
}
9093
}
9194
}
9295
}
@@ -132,23 +135,3 @@ if (gradle.startParameter.taskNames.contains("eclipse")) {
132135
}
133136
}
134137

135-
public class LibEntry implements ClasspathEntry {
136-
private String path;
137-
138-
LibEntry(String path) {
139-
this.path = path;
140-
}
141-
142-
@Override
143-
String getKind() {
144-
return "lib"
145-
}
146-
147-
@Override
148-
void appendNode(Node node) {
149-
node.appendNode("classpathentry", Map.of(
150-
"kind", "lib",
151-
"path", path
152-
))
153-
}
154-
}

gradle/ide/eclipse/dot.settings/org.eclipse.jdt.core.prefs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ eclipse.preferences.version=1
33
org.eclipse.jdt.core.compiler.codegen.targetPlatform=@eclipseJavaVersion@
44
org.eclipse.jdt.core.compiler.compliance=@eclipseJavaVersion@
55
org.eclipse.jdt.core.compiler.source=@eclipseJavaVersion@
6+
# this turns off split package checks, which gradle-api jar contains. https://github.com/gradle/gradle/issues/19577
7+
org.eclipse.jdt.core.compiler.ignoreUnnamedModuleForSplitPackage=enabled
68
# Note: all compiler flags are defined in ECJ linter configuration
79
@ecj-lint-config@
810
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false

0 commit comments

Comments
 (0)