-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-groovy.gradle
More file actions
58 lines (56 loc) · 1.99 KB
/
Copy pathinit-groovy.gradle
File metadata and controls
58 lines (56 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import org.gradle.plugins.ide.eclipse.model.EclipseModel
gradle.projectsEvaluated { g ->
if (System.getProperty("eclipse.application") == null) return
def allprojects = g.rootProject.allprojects
allprojects.each { p ->
if (p.plugins.hasPlugin('eclipse') && p.plugins.hasPlugin('groovy')) {
EclipseModel eclipseModel = (EclipseModel) p.property("eclipse")
String[] taskNames = [ "compileGroovy", "compileTestGroovy" ]
if (GradleVersion.version(p.getGradle().getGradleVersion()) >= GradleVersion.version("5.4")) {
for (final String taskName : taskNames) {
try {
Task task = p.getTasks().getByName(taskName)
eclipseModel.synchronizationTasks taskName
} catch (Exception e) {
// ignore
}
}
}
eclipseModel.classpath.file.whenMerged { cp ->
File projectDir = p.getProjectDir()
for (final String taskName : taskNames) {
Task task
try {
task = p.getTasks().getByName(taskName)
} catch (UnknownTaskException e) {
task = null;
}
if (task == null) {
continue
}
if (task.hasProperty("destinationDirectory")) {
def prop = task.destinationDirectory;
Object outputDir = null
if (prop instanceof org.gradle.api.file.DirectoryProperty) {
outputDir = prop.asFile.getOrNull()
} else if (prop instanceof File) {
outputDir = prop
}
if (outputDir != null && outputDir.exists()) {
cp.entries.removeAll { it instanceof org.gradle.plugins.ide.eclipse.model.Library && it.path.equals(outputDir.toString()) }
Object entry = new org.gradle.plugins.ide.eclipse.model.Library(fileReference(outputDir))
entry.exported = true
entry.entryAttributes.put("groovy_generated", "true")
entry.entryAttributes.put("optional", "true")
entry.entryAttributes.put("ignore_optional_problems", "true")
if (taskName == 'compileTestGroovy') {
entry.entryAttributes.put("test", "true")
}
cp.entries.add(entry)
}
}
}
}
}
}
}