1
- import org.gradle.plugins.ide.eclipse.model.AccessRule
2
1
apply plugin : " eclipse"
3
2
4
3
// ensure that source code is generated, otherwise class `BstLexer` cannot be found
@@ -11,22 +10,25 @@ eclipseJdt.doLast {
11
10
f. append(' encoding/<project>=UTF-8' )
12
11
}
13
12
eclipse {
14
- project {
15
- natures ' org.eclipse.buildship.core.gradleprojectnature'
16
- }
17
-
18
13
classpath {
19
14
file {
20
15
whenMerged {
21
- entries. findAll { isModule(it) }. each { // (1)
16
+ entries. findAll { isModule(it) }. each { // this was already necessary to build modular projects
22
17
it. entryAttributes[' module' ] = ' true'
23
18
}
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' ;
24
22
25
- entries. findAll { isSource(it) && isTestScope(it) }. each {
23
+ entries. findAll { isSource(it) && isTestScope(it) }. each { // mark test source folders
26
24
it. entryAttributes[' test' ] = ' true'
27
25
}
28
26
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
30
32
it. entryAttributes[' test' ] = ' true'
31
33
}
32
34
}
@@ -39,10 +41,19 @@ eclipse {
39
41
}
40
42
41
43
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
44
50
boolean isSource (entry ) { return entry. properties. kind. equals(' src' ); }
45
51
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
+ };
46
57
47
58
// add formatter and cleanup settings to Eclipse settings
48
59
// see http://stackoverflow.com/a/27461890/873282
@@ -465,7 +476,7 @@ tasks.eclipse.doFirst {
465
476
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
466
477
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
467
478
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
468
- ''' . stripIndent())
479
+ ''' . stripIndent())
469
480
470
481
File jdt_ui_prefs = file(" ${ project.projectDir} /.settings/org.eclipse.jdt.ui.prefs" )
471
482
if (jdt_ui_prefs. exists()) {
@@ -597,6 +608,6 @@ tasks.eclipse.doFirst {
597
608
sp_cleanup.use_this_for_non_static_method_access=false
598
609
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false
599
610
sp_cleanup.use_type_arguments=false
600
- ''' . stripIndent())
611
+ ''' . stripIndent())
601
612
}
602
- }
613
+ }
0 commit comments