You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/05/24 02:10:56 UTC
[groovy] 01/05: Update eclipse gradle scripts
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 73f999e5979a60ff382c1303688496492a02a5d2
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed May 22 14:40:40 2019 -0500
Update eclipse gradle scripts
---
.gitignore | 17 +++--
gradle/eclipse.gradle | 109 +++++++++++++++++----------
subprojects/groovy-docgenerator/build.gradle | 4 +
subprojects/groovy-groovydoc/build.gradle | 9 +++
subprojects/groovy-groovysh/build.gradle | 4 +
subprojects/groovy-json/build.gradle | 6 +-
subprojects/groovy-servlet/build.gradle | 6 +-
subprojects/groovy-test/build.gradle | 4 +
subprojects/tests-vm8/build.gradle | 4 +
9 files changed, 116 insertions(+), 47 deletions(-)
diff --git a/.gitignore b/.gitignore
index 1ba2a13..338baa0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,18 +1,21 @@
+user.gradle
+.gradle/
target/
build/
out/
-/bin/
+
*.DS_Store
+*.class
+*.swp
*~
-.gradle
+
+.idea
*.iml
*.ipr
*.iws
-.idea
-.*.swp
-*.class
-user.gradle
+.shelf
+
.settings/
.classpath
.project
-.shelf
+bin/
diff --git a/gradle/eclipse.gradle b/gradle/eclipse.gradle
index 559004b..84be8cf 100644
--- a/gradle/eclipse.gradle
+++ b/gradle/eclipse.gradle
@@ -16,52 +16,85 @@
* specific language governing permissions and limitations
* under the License.
*/
-//most of this is just a "hack" to break the circular dependencies between projects
-//which exist because Eclipse does not distinguish between build phases (e.g. compile, test, runtime)
allprojects {
apply plugin: 'eclipse'
-
- eclipse.jdt {
- sourceCompatibility = 1.7
- targetCompatibility = 1.7
- }
-
- eclipse.classpath.file {
- whenMerged { classpath ->
- classpath.entries.removeAll{ entry -> entry.path == '/groovy-groovydoc' }
- classpath.entries.removeAll{ entry -> entry.path =~ /groovy-ant/ }
- classpath.entries.removeAll{ entry -> entry.path =~ /target/ }
- classpath.entries.unique(true){ entry -> entry.path }
+
+ eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path =~ '/target/' } // affects: cli-commons, cli-picocli, console, groovydoc, macro, servlet, swing, templates, xml
+ entries.unique(true) { entry -> entry.path } // affects: console, groovydoc, macro, servlet, swing, templates, xml
+ entries.sort(true) { entry -> "${entry.kind}:${entry.path}".toString() }
+
+ // set "test" attribute based on gradle scopes
+ entries.findAll { entry ->
+ entry.class.name in [
+ 'org.gradle.plugins.ide.eclipse.model.Library',
+ 'org.gradle.plugins.ide.eclipse.model.SourceFolder'
+ ]
+ }.each { entry ->
+ if (entry.entryAttributes['gradle_used_by_scope'] == 'test') {
+ entry.entryAttributes['test'] = 'true'
+ }
}
- withXml {
- def node = it.asNode()
- node.appendNode('classpathentry', [kind: 'lib', path: "${rootProject.jar.archivePath}"])
+ // set "test" attribute based on configuration
+ entries.findAll { entry ->
+ entry.class.name in [
+ 'org.gradle.plugins.ide.eclipse.model.ProjectDependency'
+ ]
+ }.each { entry ->
+ if (entry.path.substring(1) in project.configurations.testCompile.dependencies*.name) {
+ entry.entryAttributes['test'] = 'true'
+ }
}
}
-
+
project.tasks.eclipse.doLast {
- File groovyPrefs = file("${project.projectDir}/.settings/org.eclipse.jdt.groovy.core.prefs")
- if (!groovyPrefs.exists()) {
- groovyPrefs.append('groovy.compiler.level=-1\n')
+ file("${project.projectDir}/.settings/org.eclipse.jdt.groovy.core.prefs").with { prefs ->
+ if (!prefs.exists()) {
+ append('''\
+ eclipse.preferences.version=1
+ groovy.compiler.level=30
+ '''.stripIndent()
+ )
+ }
}
- }
-}
-eclipse.classpath.file {
- whenMerged { classpath ->
- classpath.entries.find { entry -> entry.path =~ /src\/main/ }.path = '/groovy/src/main'
- classpath.entries.find { entry -> entry.path =~ /src\/main/ }.includes = []
- classpath.entries.each { entry -> if(entry.path == 'src/test'){ entry.excludes = ['groovy/PropertyTest.groovy'] as List } }
- classpath.entries.removeAll{ entry -> entry.path == '/groovy-test' }
- classpath.entries.removeAll{ entry -> entry.path =~ /subprojects/ }
- classpath.entries.removeAll{ entry -> entry.path =~ /examples/ }
- }
- withXml {
- def node = it.asNode()
- ['groovy-test', 'groovy-groovydoc', 'groovy-jmx', 'groovy-xml', 'groovy-ant'].each{
- node.appendNode('classpathentry', [kind: 'src', path: "/groovy/subprojects/$it/src/main/groovy"])
- node.appendNode('classpathentry', [kind: 'src', path: "/groovy/subprojects/$it/src/main/java"])
+ file("${project.projectDir}/.settings/org.eclipse.core.resources.prefs").with { prefs ->
+ if (!prefs.exists()) {
+ append('''\
+ eclipse.preferences.version=1
+ encoding/<project>=UTF-8
+ '''.stripIndent()
+ )
+ }
+ }
+
+ file("${project.projectDir}/.settings/org.eclipse.core.runtime.prefs").with { prefs ->
+ if (!prefs.exists()) {
+ append('''\
+ eclipse.preferences.version=1
+ line.separator=\\n
+ '''.stripIndent()
+ )
+ }
+ }
+
+ file("${project.projectDir}/.settings/org.eclipse.jdt.ui.prefs").with { prefs ->
+ if (!prefs.exists()) {
+ append('''\
+ eclipse.preferences.version=1
+ org.eclipse.jdt.ui.ignorelowercasenames=true
+ org.eclipse.jdt.ui.importorder=;javax;java;\\#;
+ org.eclipse.jdt.ui.ondemandthreshold=99
+ org.eclipse.jdt.ui.staticondemandthreshold=99
+ '''.stripIndent()
+ )
+ }
}
- node.appendNode('classpathentry', [kind: 'src', path: '/groovy/subprojects/groovy-templates/src/main/groovy'])
}
}
+
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path == '/groovy-groovydoc' }
+}
+
+// TODO: Create tasks for cleaning the .settings files created above
diff --git a/subprojects/groovy-docgenerator/build.gradle b/subprojects/groovy-docgenerator/build.gradle
index 552d4bd..0d270e4 100644
--- a/subprojects/groovy-docgenerator/build.gradle
+++ b/subprojects/groovy-docgenerator/build.gradle
@@ -23,3 +23,7 @@ dependencies {
testCompile project(':groovy-test')
compile "com.thoughtworks.qdox:qdox:$qdoxVersion"
}
+
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path == '/groovy-xml' }
+}
diff --git a/subprojects/groovy-groovydoc/build.gradle b/subprojects/groovy-groovydoc/build.gradle
index 21b7b08..80696b1 100644
--- a/subprojects/groovy-groovydoc/build.gradle
+++ b/subprojects/groovy-groovydoc/build.gradle
@@ -26,3 +26,12 @@ dependencies {
testCompile "org.apache.ant:ant-testutil:$antVersion"
}
+compileJava {
+ doLast {
+ mkdir "$sourceSets.main.java.outputDir/META-INF"
+ }
+}
+
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path == '/groovy-xml' }
+}
diff --git a/subprojects/groovy-groovysh/build.gradle b/subprojects/groovy-groovysh/build.gradle
index 6e5e1a0..2b7dfbb 100644
--- a/subprojects/groovy-groovysh/build.gradle
+++ b/subprojects/groovy-groovysh/build.gradle
@@ -25,3 +25,7 @@ dependencies {
exclude(group: 'junit', module: 'junit')
}
}
+
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path in ['/groovy-xml', '/groovy-swing', '/groovy-templates'] }
+}
diff --git a/subprojects/groovy-json/build.gradle b/subprojects/groovy-json/build.gradle
index c9bf97a..3ff11ac 100644
--- a/subprojects/groovy-json/build.gradle
+++ b/subprojects/groovy-json/build.gradle
@@ -19,6 +19,10 @@
dependencies {
compile rootProject
testCompile project(':groovy-test')
- testRuntime project(':groovy-ant')
testCompile project(':groovy-dateutil')
+ testRuntime project(':groovy-ant') // for JavadocAssertionTests
+}
+
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path in ['/groovy-ant', '/groovy-groovydoc'] }
}
diff --git a/subprojects/groovy-servlet/build.gradle b/subprojects/groovy-servlet/build.gradle
index 3dce1cd..60faeb1 100644
--- a/subprojects/groovy-servlet/build.gradle
+++ b/subprojects/groovy-servlet/build.gradle
@@ -33,5 +33,9 @@ dependencies {
testCompile rootProject.sourceSets.test.runtimeClasspath
testCompile project(':groovy-test')
// for compilation, dependency is not necessary because the classes are loaded using Class.forName
- testCompile project(':groovy-json')
+ testRuntime project(':groovy-json')
+}
+
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path == '/groovy-json' }
}
diff --git a/subprojects/groovy-test/build.gradle b/subprojects/groovy-test/build.gradle
index c0a8bdd..e7e3d0b 100644
--- a/subprojects/groovy-test/build.gradle
+++ b/subprojects/groovy-test/build.gradle
@@ -26,4 +26,8 @@ dependencies {
testRuntime "org.apache.ant:ant-launcher:$antVersion"
}
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path == '/groovy-ant' }
+}
+
apply from: "${rootProject.projectDir}/gradle/jacoco/jacocofix.gradle"
diff --git a/subprojects/tests-vm8/build.gradle b/subprojects/tests-vm8/build.gradle
index f5c054c..3b31770 100644
--- a/subprojects/tests-vm8/build.gradle
+++ b/subprojects/tests-vm8/build.gradle
@@ -52,3 +52,7 @@ sourceSets {
}
}
}
+
+eclipse.classpath.file.whenMerged {
+ entries.removeAll { entry -> entry.path in ['/groovy-ant', '/groovy-groovydoc'] }
+}