From 54f4246bfc1c9db44264aebd2a8bbb899084790b Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 30 Sep 2019 21:30:08 +0200 Subject: [PATCH 1/2] [WIP] Improve Eclipse config Improve eclipse module path loading --- eclipse.gradle | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eclipse.gradle b/eclipse.gradle index eeaa9f4895f..fd7c582e275 100644 --- a/eclipse.gradle +++ b/eclipse.gradle @@ -16,17 +16,17 @@ eclipse { } classpath { - file { + file { whenMerged { - entries.findAll { isModule(it) }.each { //(1) + entries.findAll { isModule(it) }.each { //this was already necessary to build modular projects it.entryAttributes['module'] = 'true' } - entries.findAll { isSource(it) && isTestScope(it) }.each { + entries.findAll { isSource(it) && isTestScope(it) }.each { //mark test source folders it.entryAttributes['test'] = 'true' } - entries.findAll { isLibrary(it) && isTestScope(it) }.each { + entries.findAll { isLibrary(it) && isTestScope(it) }.each { //mark test source files it.entryAttributes['test'] = 'true' } } @@ -39,8 +39,8 @@ eclipse { } boolean isLibrary(entry) { return entry.properties.kind.equals('lib') } -boolean isTestScope(entry) { return entry.entryAttributes.get('gradle_used_by_scope').equals('test'); } -boolean isModule(entry) { isLibrary(entry) && !isTestScope(entry); } +boolean isTestScope(entry) { return ! entry.entryAttributes.get('gradle_used_by_scope').contains('main') } +boolean isModule(entry) { isLibrary(entry) && !isTestScope(entry); } //a test-scope library should be put on the classpath instead of the modulepath boolean isSource(entry) { return entry.properties.kind.equals('src'); } @@ -599,4 +599,4 @@ tasks.eclipse.doFirst { sp_cleanup.use_type_arguments=false '''. stripIndent()) } -} \ No newline at end of file +} From ba1fb959b3d1fc3b6006bbfbe0ada13c6c2febbd Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 30 Sep 2019 22:21:16 +0200 Subject: [PATCH 2/2] add open and exports for module system to java classpath remove gradle nature as eclipse buildship currently does not yet work fully with jigsaw stuff remove unused import --- eclipse.gradle | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/eclipse.gradle b/eclipse.gradle index fd7c582e275..c5121e5eb90 100644 --- a/eclipse.gradle +++ b/eclipse.gradle @@ -1,4 +1,3 @@ -import org.gradle.plugins.ide.eclipse.model.AccessRule apply plugin: "eclipse" // ensure that source code is generated, otherwise class `BstLexer` cannot be found @@ -11,21 +10,24 @@ eclipseJdt.doLast { f.append('encoding/=UTF-8') } eclipse { - project { - natures 'org.eclipse.buildship.core.gradleprojectnature' - } - classpath { - file { + file { whenMerged { entries.findAll { isModule(it) }.each { //this was already necessary to build modular projects it.entryAttributes['module'] = 'true' } + def controlsfx = entries.find { isControlsfx(it) }; + 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'; + 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'; entries.findAll { isSource(it) && isTestScope(it) }.each { //mark test source folders it.entryAttributes['test'] = 'true' } + def jreContainer = entries.find { isJREContainer(it) }; + jreContainer.entryAttributes['add-exports'] = 'javafx.controls/com.sun.javafx.scene.control=org.jabref'; + jreContainer.entryAttributes['add-opens'] = 'javafx.controls/com.sun.javafx.scene.control=org.jabref'; + entries.findAll { isLibrary(it) && isTestScope(it) }.each { //mark test source files it.entryAttributes['test'] = 'true' } @@ -39,10 +41,19 @@ eclipse { } boolean isLibrary(entry) { return entry.properties.kind.equals('lib') } -boolean isTestScope(entry) { return ! entry.entryAttributes.get('gradle_used_by_scope').contains('main') } -boolean isModule(entry) { isLibrary(entry) && !isTestScope(entry); } //a test-scope library should be put on the classpath instead of the modulepath + +boolean isTestScope(entry) { return !entry.entryAttributes.get('gradle_used_by_scope').contains('main') } + +boolean isModule(entry) { + isLibrary(entry) && !isTestScope(entry); +} //a test-scope library should be put on the classpath instead of the modulepath boolean isSource(entry) { return entry.properties.kind.equals('src'); } +boolean isControlsfx(entry) { return entry.properties.path.contains('controlsfx'); } + +boolean isJREContainer(entry) { + return entry.properties.kind == 'con' && entry.properties.path.startsWith('org.eclipse.jdt.launching.JRE_CONTAINER') +}; // add formatter and cleanup settings to Eclipse settings // see http://stackoverflow.com/a/27461890/873282 @@ -465,7 +476,7 @@ tasks.eclipse.doFirst { org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter - '''. stripIndent()) + '''.stripIndent()) File jdt_ui_prefs = file("${project.projectDir}/.settings/org.eclipse.jdt.ui.prefs") if (jdt_ui_prefs.exists()) { @@ -597,6 +608,6 @@ tasks.eclipse.doFirst { sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false sp_cleanup.use_type_arguments=false - '''. stripIndent()) + '''.stripIndent()) } }