Skip to content

Commit 631cec5

Browse files
authored
Merge pull request #5370 from JabRef/improveEclipse
Improve Eclipse config
2 parents 5d539ed + ba1fb95 commit 631cec5

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

Diff for: eclipse.gradle

+24-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.gradle.plugins.ide.eclipse.model.AccessRule
21
apply plugin: "eclipse"
32

43
// ensure that source code is generated, otherwise class `BstLexer` cannot be found
@@ -11,22 +10,25 @@ eclipseJdt.doLast {
1110
f.append('encoding/<project>=UTF-8')
1211
}
1312
eclipse {
14-
project {
15-
natures 'org.eclipse.buildship.core.gradleprojectnature'
16-
}
17-
1813
classpath {
1914
file {
2015
whenMerged {
21-
entries.findAll { isModule(it) }.each { //(1)
16+
entries.findAll { isModule(it) }.each { //this was already necessary to build modular projects
2217
it.entryAttributes['module'] = 'true'
2318
}
19+
def controlsfx = entries.find { isControlsfx(it) };
20+
controlsfx.entryAttributes['add-exports'] = 'org.controlsfx.controls/impl.org.controlsfx.skin=org.jabref:org.controlsfx.controls/org.controlsfx.control.textfield=org.jabref:org.controlsfx.controls/impl.org.controlsfx.autocompletion=org.jabref';
21+
controlsfx.entryAttributes['add-opens'] = 'org.controlsfx.controls/impl.org.controlsfx.skin=org.jabref:org.controlsfx.controls/org.controlsfx.control.textfield=org.jabref:org.controlsfx.controls/impl.org.controlsfx.autocompletion=org.jabref';
2422

25-
entries.findAll { isSource(it) && isTestScope(it) }.each {
23+
entries.findAll { isSource(it) && isTestScope(it) }.each { //mark test source folders
2624
it.entryAttributes['test'] = 'true'
2725
}
2826

29-
entries.findAll { isLibrary(it) && isTestScope(it) }.each {
27+
def jreContainer = entries.find { isJREContainer(it) };
28+
jreContainer.entryAttributes['add-exports'] = 'javafx.controls/com.sun.javafx.scene.control=org.jabref';
29+
jreContainer.entryAttributes['add-opens'] = 'javafx.controls/com.sun.javafx.scene.control=org.jabref';
30+
31+
entries.findAll { isLibrary(it) && isTestScope(it) }.each { //mark test source files
3032
it.entryAttributes['test'] = 'true'
3133
}
3234
}
@@ -39,10 +41,19 @@ eclipse {
3941
}
4042

4143
boolean isLibrary(entry) { return entry.properties.kind.equals('lib') }
42-
boolean isTestScope(entry) { return entry.entryAttributes.get('gradle_used_by_scope').equals('test'); }
43-
boolean isModule(entry) { isLibrary(entry) && !isTestScope(entry); }
44+
45+
boolean isTestScope(entry) { return !entry.entryAttributes.get('gradle_used_by_scope').contains('main') }
46+
47+
boolean isModule(entry) {
48+
isLibrary(entry) && !isTestScope(entry);
49+
} //a test-scope library should be put on the classpath instead of the modulepath
4450
boolean isSource(entry) { return entry.properties.kind.equals('src'); }
4551

52+
boolean isControlsfx(entry) { return entry.properties.path.contains('controlsfx'); }
53+
54+
boolean isJREContainer(entry) {
55+
return entry.properties.kind == 'con' && entry.properties.path.startsWith('org.eclipse.jdt.launching.JRE_CONTAINER')
56+
};
4657

4758
// add formatter and cleanup settings to Eclipse settings
4859
// see http://stackoverflow.com/a/27461890/873282
@@ -465,7 +476,7 @@ tasks.eclipse.doFirst {
465476
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
466477
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
467478
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
468-
'''. stripIndent())
479+
'''.stripIndent())
469480

470481
File jdt_ui_prefs = file("${project.projectDir}/.settings/org.eclipse.jdt.ui.prefs")
471482
if (jdt_ui_prefs.exists()) {
@@ -597,6 +608,6 @@ tasks.eclipse.doFirst {
597608
sp_cleanup.use_this_for_non_static_method_access=false
598609
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false
599610
sp_cleanup.use_type_arguments=false
600-
'''. stripIndent())
611+
'''.stripIndent())
601612
}
602-
}
613+
}

0 commit comments

Comments
 (0)