From c007dbac060d5dd413b252a6fcf98ab2784f71de Mon Sep 17 00:00:00 2001 From: Frank Vennemeyer Date: Mon, 3 Feb 2020 20:24:28 +0100 Subject: [PATCH] Issue 483 (#519) Gradle 4 `_ext` projects converted to sub-projects of root supporting Gradle 6. GOOMPH updated to version 3.21.0. --- .gitignore | 2 +- CONTRIBUTING.md | 20 ++++++ _ext/BUILD_INSTRUCTIONS.md | 9 --- _ext/eclipse-base/README.md | 3 +- _ext/eclipse-base/build.gradle | 4 +- _ext/eclipse-base/gradle.properties | 15 +--- _ext/eclipse-cdt/README.md | 3 +- _ext/eclipse-cdt/build.gradle | 11 +-- _ext/eclipse-cdt/gradle.properties | 14 +--- _ext/eclipse-groovy/README.md | 3 +- _ext/eclipse-groovy/build.gradle | 26 ++++--- _ext/eclipse-groovy/gradle.properties | 15 +--- _ext/eclipse-jdt/README.md | 3 +- _ext/eclipse-jdt/build.gradle | 5 +- _ext/eclipse-jdt/gradle.properties | 12 +--- .../java/EclipseJdtFormatterStepImplTest.java | 11 ++- _ext/eclipse-wtp/README.md | 3 +- _ext/eclipse-wtp/build.gradle | 64 ++++++++--------- _ext/eclipse-wtp/gradle.properties | 19 ++--- _ext/gradle/java-publish.gradle | 37 ++++------ _ext/gradle/java-setup.gradle | 69 ++----------------- _ext/gradle/p2-fat-jar-setup.gradle | 31 ++------- _ext/gradle/update-lockfile.gradle | 6 ++ build.gradle | 6 +- gradle.properties | 3 + gradle/java-setup.gradle | 2 +- ide/build.gradle | 2 +- settings.gradle | 22 ++++++ 28 files changed, 177 insertions(+), 243 deletions(-) delete mode 100644 _ext/BUILD_INSTRUCTIONS.md create mode 100644 _ext/gradle/update-lockfile.gradle diff --git a/.gitignore b/.gitignore index e820110b1b..8b95e1b44f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ gradle-app.setting !gradle-wrapper.jar #Gradle-Lock files in _ext just serving as an input for lib-extra -_ext/*/gradle/dependency-locks/compileClasspath.lockfile +_ext/*/gradle/dependency-locks/*.lockfile ### Eclipse ### *.pydevproject diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36a989760b..4d186267b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -101,6 +101,26 @@ Here's a checklist for creating a new step for Spotless: - [ ] Test class has test methods to verify behavior. - [ ] Test class has a test method `equality()` which tests equality using `StepEqualityTester` (see existing methods for examples). +## How to enable the _ext projects + +The `_ext` projects are disabled per default, since: + +* some of the projects perform vasts downloads at configuration time + +* the downloaded content may change on server side and break CI builds + + +The `_ext` can be activated via the root project property `com.diffplug.spotless.include_ext`. + +Activate the the property via command line, like for example: + +``` +gradlew -Pcom.diffplug.spotless.include.ext=true build + +``` + +Or set the property in your user `gradle.properties` file, which is especially recommended if you like to work with the `_ext` projects using IDEs. + ## How to add a new plugin for a build system The gist of it is that you will have to: diff --git a/_ext/BUILD_INSTRUCTIONS.md b/_ext/BUILD_INSTRUCTIONS.md deleted file mode 100644 index 377daf9ade..0000000000 --- a/_ext/BUILD_INSTRUCTIONS.md +++ /dev/null @@ -1,9 +0,0 @@ - -The `_ext` builds are currently tested only with gradle `4.4.1`. They are known not to work for the current wrapper version. - -To install the correct version using [sdkman](https://sdkman.io/install): - -- `sdk install gradle 4.4.1` -- `sdk default gradle 4.4.1` - -Then you can do `gradle -b _ext/{DIR}/build.gradle publish`. `gradlew` will not work. diff --git a/_ext/eclipse-base/README.md b/_ext/eclipse-base/README.md index 6b8ac83728..debe3be28b 100644 --- a/_ext/eclipse-base/README.md +++ b/_ext/eclipse-base/README.md @@ -55,7 +55,8 @@ is included in your formatter fat JAR, the directory structure should be: ## Build -To publish a new version, update the `_ext/eclipse-base/gradle.properties` appropriately and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS). +To publish a new version, update the `_ext/eclipse-base/gradle.properties` appropriately and see [CONTRIBUTING.md](../../CONTRIBUTING.md) how to enable +`_ext` projects. ## License diff --git a/_ext/eclipse-base/build.gradle b/_ext/eclipse-base/build.gradle index 6d98470d71..f517920132 100644 --- a/_ext/eclipse-base/build.gradle +++ b/_ext/eclipse-base/build.gradle @@ -1,5 +1,5 @@ -apply from: rootProject.file('../gradle/java-setup.gradle') -apply from: rootProject.file('../gradle/java-publish.gradle') +apply from: rootProject.file('_ext/gradle/java-setup.gradle') +apply from: rootProject.file('_ext/gradle/java-publish.gradle') ext { developers = [ diff --git a/_ext/eclipse-base/gradle.properties b/_ext/eclipse-base/gradle.properties index aebbc9672a..2e43614b3a 100644 --- a/_ext/eclipse-base/gradle.properties +++ b/_ext/eclipse-base/gradle.properties @@ -1,18 +1,9 @@ # Mayor versions correspond to the supported Eclipse core version. # Minor version is incremented for features or incompatible changes (including changes to supported dependency versions). # Patch version is incremented for backward compatible patches of this library. -ext_version=3.2.1 -ext_artifactId=spotless-eclipse-base -ext_description=Eclipse bundle controller and services for Spotless - -ext_org=diffplug -ext_group=com.diffplug.spotless - -# Build requirements -ext_VER_JAVA=1.8 +version=3.2.1 +artifactId=spotless-eclipse-base +description=Eclipse bundle controller and services for Spotless # Compile dependencies VER_ECLIPSE_CORE_RESOURCES=[3.13.400,4.0.0[ - -# Provided dependencies -VER_SLF4J=[1.6,2.0[ \ No newline at end of file diff --git a/_ext/eclipse-cdt/README.md b/_ext/eclipse-cdt/README.md index 1719323872..842fbad606 100644 --- a/_ext/eclipse-cdt/README.md +++ b/_ext/eclipse-cdt/README.md @@ -2,7 +2,8 @@ Eclipse CDT is not available in a form which can be easily consumed by maven or gradle. To fix this, we publish Eclipse's formatter and all its dependencies, along with a small amount of glue code, into the `com.diffplug.gradle.spotless:spotless-eclipse-cdt` artifact. -To publish a new version, update the `_ext/eclipse-cdt/gradle.properties` appropriately and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS). +To publish a new version, update the `_ext/eclipse-cdt/gradle.properties` appropriately and see [CONTRIBUTING.md](../../CONTRIBUTING.md) how to enable +`_ext` projects. ## License diff --git a/_ext/eclipse-cdt/build.gradle b/_ext/eclipse-cdt/build.gradle index 278cf039c3..dc0da823a9 100644 --- a/_ext/eclipse-cdt/build.gradle +++ b/_ext/eclipse-cdt/build.gradle @@ -4,15 +4,16 @@ ext { ] p2Repository = "https://download.eclipse.org/tools/cdt/releases/${VER_ECLIPSE_CDT}" - + p2Dependencies = [ 'org.eclipse.cdt.core':'+', // CodeFormatter and related - ] + ] } -apply from: rootProject.file('../gradle/p2-fat-jar-setup.gradle') -apply from: rootProject.file('../gradle/java-publish.gradle') +apply from: rootProject.file('_ext/gradle/update-lockfile.gradle') +apply from: rootProject.file('_ext/gradle/p2-fat-jar-setup.gradle') +apply from: rootProject.file('_ext/gradle/java-publish.gradle') dependencies { @@ -25,7 +26,7 @@ dependencies { compile "com.ibm.icu:icu4j:${VER_IBM_ICU}" // Required to by CCorePlugin calling PositionTrackerManager compile "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLISPE_PLATFORM}" - + testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}") } diff --git a/_ext/eclipse-cdt/gradle.properties b/_ext/eclipse-cdt/gradle.properties index a5109e3128..5a1923fe55 100644 --- a/_ext/eclipse-cdt/gradle.properties +++ b/_ext/eclipse-cdt/gradle.properties @@ -1,14 +1,9 @@ # Versions correspond to the Eclipse-CDT version used for the fat-JAR. # See https://www.eclipse.org/cdt/ for further information about Eclipse-CDT versions. # Patch version can be incremented independently for backward compatible patches of this library. -ext_version=9.9.0 -ext_artifactId=spotless-eclipse-cdt -ext_description=Eclipse's CDT C/C++ formatter bundled for Spotless -ext_org=diffplug -ext_group=com.diffplug.spotless - -# Build requirements -ext_VER_JAVA=1.8 +version=9.9.0 +artifactId=spotless-eclipse-cdt +description=Eclipse's CDT C/C++ formatter bundled for Spotless # Compile dependencies VER_ECLIPSE_CDT=9.9 @@ -16,6 +11,3 @@ VER_SPOTLESS_ECLISPE_BASE=[3.2.0,4.0.0[ VER_ECLISPE_JFACE=[3.15.300,4.0.0[ VER_ECLISPE_PLATFORM=[3.6.700,4.0.0[ VER_IBM_ICU=[61,62[ - -# Provided dependencies -VER_SLF4J=[1.6,2.0[ \ No newline at end of file diff --git a/_ext/eclipse-groovy/README.md b/_ext/eclipse-groovy/README.md index 58e6a01342..c565d04cf2 100644 --- a/_ext/eclipse-groovy/README.md +++ b/_ext/eclipse-groovy/README.md @@ -5,7 +5,8 @@ To fix this, we publish Groovy-Eclipse's formatter and all its dependencies, alo ## Build -To publish a new version, update the `_ext/eclipse-groovy/gradle.properties` appropriately and and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS). +To publish a new version, update the `_ext/eclipse-groovy/gradle.properties` appropriately and and see [CONTRIBUTING.md](../../CONTRIBUTING.md) how to enable +`_ext` projects. ## License diff --git a/_ext/eclipse-groovy/build.gradle b/_ext/eclipse-groovy/build.gradle index 53dc0895f3..99e09443b3 100644 --- a/_ext/eclipse-groovy/build.gradle +++ b/_ext/eclipse-groovy/build.gradle @@ -2,12 +2,12 @@ ext { developers = [ fvgh: [ name: 'Frank Vennemeyer', email: 'frankgh@zoho.com' ], ] - + p2Repository = "https://dist.springsource.org/release/GRECLIPSE/${VER_GRECLIPSE}/e${VER_ECLIPSE}" - p2Dependencies = [ + p2Dependencies = [ 'org.codehaus.groovy.eclipse.refactoring':'+', // GroovyFormatter and related - + // The following lists does not reflect the complete transitive required packages, but // the once used during code formatting 'org.codehaus.groovy':'+', // Groovy compiler patches supporting use within GrEclipse and Groovy itself @@ -18,18 +18,24 @@ ext { internalJars = [ //Jars included by org.codehaus.groovy - "**/groovy-${VER_GROOVY}-indy", // Use Groovy compiler compatible with GrEclipse instead of localGroovy - '**/groovy-eclipse', // Patches/Overrides some of the Groovy compiler classes - '**/eclipse-trace', // Provides logging capabilities for groovy-eclipse - + ////////////////////////////////////////////////////////////////////////// + // Use Groovy compiler compatible with GrEclipse instead of localGroovy + "**/groovy-${VER_GROOVY}-indy", + // Patches/Overrides some of the Groovy compiler classes + '**/groovy-eclipse', + // Provides logging capabilities for groovy-eclipse + '**/eclipse-trace', //Jars included by org.eclipse.jdt.groovy.core - '**/nlcl' //Non locking class loader used by groovy compiler + ////////////////////////////////////////////////////////////////////////// + //Non locking class loader used by groovy compiler + '**/nlcl' ] } -apply from: rootProject.file('../gradle/p2-fat-jar-setup.gradle') -apply from: rootProject.file('../gradle/java-publish.gradle') +apply from: rootProject.file('_ext/gradle/update-lockfile.gradle') +apply from: rootProject.file('_ext/gradle/p2-fat-jar-setup.gradle') +apply from: rootProject.file('_ext/gradle/java-publish.gradle') dependencies { compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}" diff --git a/_ext/eclipse-groovy/gradle.properties b/_ext/eclipse-groovy/gradle.properties index c0eff9e8d8..1410bdb150 100644 --- a/_ext/eclipse-groovy/gradle.properties +++ b/_ext/eclipse-groovy/gradle.properties @@ -1,15 +1,9 @@ # Versions correspond to the Groovy-Eclipse version used for the fat-JAR. # See https://github.com/groovy/groovy-eclipse/releases for further information about Groovy-Eclipse versions. # Patch version can be incremented independently for backward compatible patches of this library. -ext_version=3.5.0 -ext_artifactId=spotless-eclipse-groovy -ext_description=Groovy Eclipse's formatter bundled for Spotless - -ext_org=diffplug -ext_group=com.diffplug.spotless - -# Build requirements -ext_VER_JAVA=1.8 +version=3.5.0 +artifactId=spotless-eclipse-groovy +description=Groovy Eclipse's formatter bundled for Spotless # Compile VER_ECLIPSE=4.13 @@ -17,6 +11,3 @@ VER_SPOTLESS_ECLISPE_BASE=[3.2.0,4.0.0[ VER_ECLISPE_JFACE=[3.15.300,4.0.0[ VER_GRECLIPSE=3.5.0 VER_GROOVY=3.0.0 - -# Provided dependencies -VER_SLF4J=[1.6,2.0[ \ No newline at end of file diff --git a/_ext/eclipse-jdt/README.md b/_ext/eclipse-jdt/README.md index 0544fdf90e..014b58e732 100644 --- a/_ext/eclipse-jdt/README.md +++ b/_ext/eclipse-jdt/README.md @@ -4,7 +4,8 @@ Eclipse JDT and its dependencies require a large amount of byte code. Hence they should not be directly be required by the Spotless, but only be requested in case they are configured by the Spotless configuration. Hence we publish Eclipse's formatter and all its dependencies, along with a small amount of glue code, into the `com.diffplug.gradle.spotless:spotless-eclipse-jdt` artifact. -To publish a new version, update the `_ext/eclipse-jdt/gradle.properties` appropriately and and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS). +To publish a new version, update the `_ext/eclipse-jdt/gradle.properties` appropriately and and see [CONTRIBUTING.md](../../CONTRIBUTING.md) how to enable +`_ext` projects. ## License diff --git a/_ext/eclipse-jdt/build.gradle b/_ext/eclipse-jdt/build.gradle index e079a42c41..6d3d5e4ec4 100644 --- a/_ext/eclipse-jdt/build.gradle +++ b/_ext/eclipse-jdt/build.gradle @@ -1,5 +1,6 @@ -apply from: rootProject.file('../gradle/java-setup.gradle') -apply from: rootProject.file('../gradle/java-publish.gradle') +apply from: rootProject.file('_ext/gradle/update-lockfile.gradle') +apply from: rootProject.file('_ext/gradle/java-setup.gradle') +apply from: rootProject.file('_ext/gradle/java-publish.gradle') ext { developers = [ diff --git a/_ext/eclipse-jdt/gradle.properties b/_ext/eclipse-jdt/gradle.properties index 48116f43ec..497d352750 100644 --- a/_ext/eclipse-jdt/gradle.properties +++ b/_ext/eclipse-jdt/gradle.properties @@ -1,14 +1,8 @@ # Mayor/Minor versions correspond to the minimum Eclipse version supported/tested. # Patch version is incremented for backward compatible patches of this library. -ext_version=4.12.0 -ext_artifactId=spotless-eclipse-jdt -ext_description=Eclipse's JDT formatter bundled for Spotless - -ext_org=diffplug -ext_group=com.diffplug.spotless - -# Build requirements -ext_VER_JAVA=1.8 +version=4.12.0 +artifactId=spotless-eclipse-jdt +description=Eclipse's JDT formatter bundled for Spotless # Compile VER_ECLIPSE_JDT_CORE=[3.12.0,4.0.0[ diff --git a/_ext/eclipse-jdt/src/test/java/com/diffplug/spotless/extra/eclipse/java/EclipseJdtFormatterStepImplTest.java b/_ext/eclipse-jdt/src/test/java/com/diffplug/spotless/extra/eclipse/java/EclipseJdtFormatterStepImplTest.java index e45d9a0013..18a0ca69b2 100644 --- a/_ext/eclipse-jdt/src/test/java/com/diffplug/spotless/extra/eclipse/java/EclipseJdtFormatterStepImplTest.java +++ b/_ext/eclipse-jdt/src/test/java/com/diffplug/spotless/extra/eclipse/java/EclipseJdtFormatterStepImplTest.java @@ -61,9 +61,16 @@ public void defaultFormat() throws Throwable { * Spotless anyhow provides possibilities to change exception behavior. * Furthermore it is assumed that Spotless runs on compile-able code. */ - @Test(expected = IndexOutOfBoundsException.class) public void invalidFormat() throws Throwable { - format(FORMATTED.replace("void hello() {", "void hello() "), config -> {}); + try { + String output = format(FORMATTED.replace("void hello() {", "void hello() "), config -> {}); + assertTrue("Incomplete Java not formatted on best effort basis.", output.contains("void hello() " + LINE_DELIMITER)); + } catch (IndexOutOfBoundsException e) { + /* + * Some JDT versions throw exception, but this changed again in later versions. + * Anyhow, exceptions are acceptable, since Spotless should fromat valid Java code. + */ + } } @Test diff --git a/_ext/eclipse-wtp/README.md b/_ext/eclipse-wtp/README.md index 98279651bd..879f299377 100644 --- a/_ext/eclipse-wtp/README.md +++ b/_ext/eclipse-wtp/README.md @@ -2,7 +2,8 @@ Eclipse WTP is not available in a form which can be easily consumed by maven or gradle. To fix this, we publish Eclipse's WTP formatters, along with a small amount of glue code, into the `com.diffplug.spotless.extra:spotless-eclipse-wtp` artifact. -To publish a new version, update the `_ext/eclipse-wtp/gradle.properties` appropriately and and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS). +To publish a new version, update the `_ext/eclipse-wtp/gradle.properties` appropriately and and see [CONTRIBUTING.md](../../CONTRIBUTING.md) how to enable +`_ext` projects. ## License diff --git a/_ext/eclipse-wtp/build.gradle b/_ext/eclipse-wtp/build.gradle index 3d79503157..df58bffb84 100644 --- a/_ext/eclipse-wtp/build.gradle +++ b/_ext/eclipse-wtp/build.gradle @@ -1,11 +1,8 @@ -plugins { - id 'com.diffplug.gradle.spotless' version '3.27.0' -} ext { developers = [ fvgh: [ name: 'Frank Vennemeyer', email: 'frankgh@zoho.com' ], ] - + p2Repository = "https://download.eclipse.org/webtools/repository/${VER_ECLIPSE_WTP}" p2Dependencies = [ @@ -14,10 +11,10 @@ ext { 'org.eclipse.wst.sse.core':'+', // Structure models 'org.eclipse.wst.common.uriresolver':'+', // URI resolver for model queries 'org.eclipse.wst.dtd.core':'+', // Support DTD extensions - + // XML Formatter - Dependencies 'org.eclipse.wst.xsd.core':'+', // Support XSD extensions - + // JS Formatter - Dependencies 'org.eclipse.wst.jsdt.core':'+', // DefaultCodeFormatter and related 'org.eclipse.wst.jsdt.ui':'+', // Functionality to format comments @@ -25,23 +22,28 @@ ext { // JSON Formatter - Dependencies 'org.eclipse.wst.json.core':'+', // FormatProcessorJSON and related 'org.eclipse.json':'+', // Provides JSON node interfaces - + // CSS Formatter - Dependencies 'org.eclipse.wst.css.core':'+', // FormatProcessorCSS and related - + // HTML Formatter - Dependencies 'org.eclipse.wst.html.core':'+', // HTMLFormatProcessorImpl and related ] - + jarInclude = [ - '**/*.class', // Take all classes - '**/*.properties', // Text resources (for messages, etc) - '**/*.rsc', // JSDT requires gramar files - '**/*.xml', // Plugin XML and other resources - '*.html', // License information about the included JARs, + '**/*.class', + // Take all classes + '**/*.properties', + // Text resources (for messages, etc) + '**/*.rsc', + // JSDT requires gramar files + '**/*.xml', + // Plugin XML and other resources + '*.html', + // License information about the included JARs, 'META-INF/**' // Plugin manifest and addtional information ] - + fatJarResourcesMap = [ 'org.eclipse.wst.common.uriresolver': 'org.eclipse.wst.common.uriresolver.internal.provisional', 'org.eclipse.wst.css.core': 'org.eclipse.wst.css.core.internal', @@ -53,14 +55,15 @@ ext { ] } -apply from: rootProject.file('../gradle/p2-fat-jar-setup.gradle') -apply from: rootProject.file('../gradle/java-publish.gradle') +apply from: rootProject.file('_ext/gradle/update-lockfile.gradle') +apply from: rootProject.file('_ext/gradle/p2-fat-jar-setup.gradle') +apply from: rootProject.file('_ext/gradle/java-publish.gradle') dependencies { compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}" // Required by most WPT formatters compile "com.ibm.icu:icu4j:${VER_IBM_ICU}" - // The XSD/DTD and other models are defined with EMF. + // The XSD/DTD and other models are defined with EMF. compile "org.eclipse.emf:org.eclipse.emf.common:${VER_ECLISPE_EMF}" compile "org.eclipse.emf:org.eclipse.emf.ecore:${VER_ECLISPE_EMF}" // Some WPT plugins requires OSGI bundle interfaces (but not effectively used) @@ -71,7 +74,7 @@ dependencies { compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") { exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt' } - // Some WPT plugins use the EFS for storing temporary worspace data + // Some WPT plugins use the EFS for storing temporary worspace data compile "org.eclipse.platform:org.eclipse.core.filesystem:${VER_ECLISPE_EFS}" // Required by org.eclipse.wst.xsd.core compile "org.eclipse.xsd:org.eclipse.xsd:${VER_ECLISPE_XSD}" @@ -98,33 +101,26 @@ sourceSets { * Eclipse framework. */ test { - //Skip default tests, which would run every test case. - exclude '**' + //Skip default tests, which would run every test case. + exclude '**' } //Instead make a separate test task per case def testLocation = 'src/test/java' fileTree(dir: testLocation).include('**/*Test.java').each { file -> def testFile = file.getName().replace(".java", "") - def filePath = file.getAbsolutePath().replace(".java", "**") //Don't ask me why the task is not happy when it gets no asterisk + def filePath = file.getAbsolutePath().replace(".java", "**") //Don't ask me why the task is not happy when it gets no asterisk filePath = filePath.substring(filePath.lastIndexOf(testLocation) + testLocation.length() + 1) task "${testFile}"(type: Test) { group = LifecycleBasePlugin.VERIFICATION_GROUP description = "Runs ${testFile} integration test." include "${filePath}" - reports { - html.destination = new File("$buildDir/reports/${testFile}") - junitXml.destination = new File("$buildDir/${testFile}") - } - //classpath = jar.outputs.files + sourceSets.test.output + sourceSets.test.compileClasspath + reports { + html.destination = new File("$buildDir/reports/${testFile}") + junitXml.destination = new File("$buildDir/${testFile}") + } + //classpath = jar.outputs.files + sourceSets.test.output + sourceSets.test.compileClasspath mustRunAfter tasks.jar } test.dependsOn "${testFile}" } - -spotless { - format 'xml', { - target 'src/main/resources/**/*.xml' - eclipseWtp('xml').configFile 'spotless.xmlformat.prefs' - } -} diff --git a/_ext/eclipse-wtp/gradle.properties b/_ext/eclipse-wtp/gradle.properties index 142768223f..70533e6862 100644 --- a/_ext/eclipse-wtp/gradle.properties +++ b/_ext/eclipse-wtp/gradle.properties @@ -1,15 +1,9 @@ # Versions correspond to the Eclipse-WTP version used for the fat-JAR. # See https://www.eclipse.org/webtools/ for further information about Eclipse-WTP versions. # Patch version can be incremented independently for backward compatible patches of this library. -ext_version=3.15.1 -ext_artifactId=spotless-eclipse-wtp -ext_description=Eclipse's WTP formatters bundled for Spotless - -ext_org=diffplug -ext_group=com.diffplug.spotless - -# Build requirements -ext_VER_JAVA=1.8 +version=3.15.1 +artifactId=spotless-eclipse-wtp +description=Eclipse's WTP formatters bundled for Spotless # Compile VER_ECLIPSE_WTP=2019-09 @@ -19,8 +13,7 @@ VER_ECLISPE_EMF=[2.16.0,3.0.0[ VER_ECLIPSE_OSGI_SERVICES=[3.8.0,4.0.0[ VER_ECLIPSE_FILE_BUFFERS=[3.6.700,4.0.0[ VER_ECLISPE_JFACE=[3.15.300,4.0.0[ -VER_ECLISPE_EFS=[1.7.500,2.0.0[ +#VER_ECLISPE_EFS=[1.7.500,2.0.0[ +#TODO: 1.7.600 changed bundle activation. Code adaptation required. +VER_ECLISPE_EFS=1.7.500 VER_ECLISPE_XSD=[2.12.0,3.0.0[ - -# Provided dependencies -VER_SLF4J=[1.6,2.0[ \ No newline at end of file diff --git a/_ext/gradle/java-publish.gradle b/_ext/gradle/java-publish.gradle index 0cae2aaae7..b620fc3858 100644 --- a/_ext/gradle/java-publish.gradle +++ b/_ext/gradle/java-publish.gradle @@ -1,14 +1,5 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' - } -} - -apply plugin: com.jfrog.bintray.gradle.BintrayPlugin apply plugin: 'maven-publish' +apply plugin: 'com.jfrog.bintray' task sourcesJar(type: Jar) { classifier = 'sources' @@ -20,7 +11,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) { from javadoc.destinationDir } -def isSnapshot = ext_version.endsWith('-SNAPSHOT') +def isSnapshot = version.endsWith('-SNAPSHOT') // pulls the credentials from either the environment variable or gradle.properties def lookup = { key, defaultVal -> if (System.env[key] != null) { @@ -36,9 +27,9 @@ publishing { publications { mavenJava(MavenPublication) { - groupId project.ext_group - artifactId project.ext_artifactId - version project.ext_version + groupId project.group + artifactId project.artifactId + version project.version from components.java artifact sourcesJar artifact javadocJar @@ -48,13 +39,13 @@ publishing { // add MavenCentral requirements to the POM asNode().children().last() + { resolveStrategy = Closure.DELEGATE_FIRST - name project.ext_artifactId - description project.ext_description - url "https://github.com/${project.ext_org}/${rootProject.name}" + name project.artifactId + description project.description + url "https://github.com/${project.org}/${rootProject.name}" scm { - url "https://github.com/${project.ext_org}/${rootProject.name}" - connection "scm:git:https://github.com/${project.ext_org}/${rootProject.name}.git" - developerConnection "scm:git:ssh:git@github.com/${project.ext_org}/${rootProject.name}.git" + url "https://github.com/${project.org}/${rootProject.name}" + connection "scm:git:https://github.com/${project.org}/${rootProject.name}.git" + developerConnection "scm:git:ssh:git@github.com/${project.org}/${rootProject.name}.git" } licenses { license { @@ -101,10 +92,10 @@ if (!isSnapshot) { publish = true pkg { repo = 'opensource' - name = project.ext_artifactId - userOrg = project.ext_org + name = project.artifactId + userOrg = project.org version { - name = project.ext_version + name = project.version mavenCentralSync { user = lookup('nexus_user', 'unknown_nexus_user') password = lookup('nexus_pass', 'unknown_nexus_user') diff --git a/_ext/gradle/java-setup.gradle b/_ext/gradle/java-setup.gradle index 6d8bd31873..0ce5af5cb9 100644 --- a/_ext/gradle/java-setup.gradle +++ b/_ext/gradle/java-setup.gradle @@ -1,78 +1,19 @@ ////////// // JAVA // ////////// -repositories { - mavenCentral() - jcenter() - /* Allow access of local SNAPSHOT builds. Sanity of dependencies - is guranteed by the lib-extra build. */ - mavenLocal() -} +apply from: rootProject.file('gradle/java-setup.gradle') // setup java apply plugin: 'java' -sourceCompatibility = ext_VER_JAVA -targetCompatibility = ext_VER_JAVA +// Show warning locations tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' options.compilerArgs << "-Xlint:unchecked" options.compilerArgs << "-Xlint:deprecation" } -// Use file locking -configurations { - compileClasspath { - def gradleVersion = GradleVersion.current() - def requiredVersion = GradleVersion.version('4.8') - if (gradleVersion >= requiredVersion) { - resolutionStrategy.activateDependencyLocking() - } - } -} - - -///////////// -// ECLIPSE // -///////////// -apply plugin: 'eclipse' -eclipse { - classpath { - downloadSources true - downloadJavadoc true - } -} -// always create fresh projects -tasks.eclipse.dependsOn(cleanEclipse) - -////////////// -// FINDBUGS // -////////////// -apply plugin: 'findbugs' -findbugs { - toolVersion = '3.0.1' - sourceSets = [ - // don't check the test code - sourceSets.main - ] - ignoreFailures = false // bug free or it doesn't ship! - reportsDir = file('build/findbugs') - effort = 'max' // min|default|max - reportLevel = 'medium' // low|medium|high (low = sensitive to even minor mistakes) - omitVisitors = [] // bugs that we want to ignore -} -// HTML instead of XML -tasks.withType(FindBugs) { - reports { - xml.enabled = false - html.enabled = true - } -} -// we'll want the findbugs annotations (they don't have a 3.0.1 version) +//Currently testlib is not used by _ext. Hence the external dependencies are added here. dependencies { - compileOnly 'com.google.code.findbugs:annotations:3.0.0' - compileOnly 'com.google.code.findbugs:jsr305:3.0.0' - - testImplementation 'junit:junit:4.12' - testImplementation 'org.assertj:assertj-core:3.5.2' + testImplementation "junit:junit:${VER_JUNIT}" + testImplementation "org.assertj:assertj-core:${VER_ASSERTJ}" } diff --git a/_ext/gradle/p2-fat-jar-setup.gradle b/_ext/gradle/p2-fat-jar-setup.gradle index dd404e1a31..25cb9ddcc5 100644 --- a/_ext/gradle/p2-fat-jar-setup.gradle +++ b/_ext/gradle/p2-fat-jar-setup.gradle @@ -1,16 +1,6 @@ -apply from: rootProject.file('../gradle/java-setup.gradle') - -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "com.diffplug.gradle:goomph:3.17.4" - } -} -apply plugin: com.diffplug.gradle.p2.AsMavenPlugin +apply from: rootProject.file('_ext/gradle/java-setup.gradle') + +apply plugin: 'com.diffplug.p2.asmaven' ext { // P2 Repository URL @@ -27,7 +17,7 @@ ext { internalJars = [] } - // Include form the JARs, which goes into a fat-jar with the spottless formatter interface. + // Include form the JARs, which goes into a fat-jar with the spottless formatter interface. if (!project.hasProperty('jarInclude')) { jarInclude = [ '**/*.class', // Take all classes @@ -38,15 +28,7 @@ ext { ] } - // Exclude form the JARs, which goes into a fat-jar with the spottless formatter interface. - if (!project.hasProperty('jarExclude')) { - jarExclude = [ - 'META-INF/*.RSA', // The eclipse jars are signed, and our fat-jar breaks the signatures - 'META-INF/*.SF', // ... so all signatures are filtered - ] - } - - // Exclude form the JARs, which goes into a fat-jar with the spottless formatter interface. + // Exclude form the JARs, which goes into a fat-jar with the spottless formatter interface. if (!project.hasProperty('jarExclude')) { jarExclude = [ 'META-INF/*.RSA', // The eclipse jars are signed, and our fat-jar breaks the signatures @@ -103,7 +85,6 @@ jar { // Unpack External Deps // ////////////////////////// import java.io.File -import org.apache.commons.io.filefilter.DirectoryFileFilter task unjarEmbeddedClasses { description = "Copies filtered set of embedded classes from the Eclise/GrEclipse dependencies to '${project.relativePath(embeddedClassesDir)}'." @@ -112,7 +93,7 @@ task unjarEmbeddedClasses { inputs.property('jarInclude', jarInclude) inputs.property('jarExclude', jarExclude) inputs.property('fatJarResourcesMap', fatJarResourcesMap) - outputs.file(embeddedClassesDir) + outputs.dir(embeddedClassesDir) doLast { embeddedClassesDir.deleteDir() diff --git a/_ext/gradle/update-lockfile.gradle b/_ext/gradle/update-lockfile.gradle new file mode 100644 index 0000000000..098d960eff --- /dev/null +++ b/_ext/gradle/update-lockfile.gradle @@ -0,0 +1,6 @@ +// Use file locking +configurations.all { + resolutionStrategy { + activateDependencyLocking() + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index f32ecac3ff..1bc5607087 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { // dependencyUpdates https://github.com/ben-manes/gradle-versions-plugin/releases id 'com.github.ben-manes.versions' version '0.22.0' // https://github.com/diffplug/goomph/blob/master/CHANGES.md - id 'com.diffplug.gradle.eclipse.resourcefilters' version '3.18.1' + id 'com.diffplug.eclipse.resourcefilters' version '3.21.0' // https://plugins.gradle.org/plugin/com.gradle.plugin-publish id 'com.gradle.plugin-publish' version '0.10.1' apply false // https://github.com/bintray/gradle-bintray-plugin/releases @@ -11,6 +11,8 @@ plugins { id 'org.jdrupes.mdoclet' version '1.0.5' apply false // https://github.com/spotbugs/spotbugs/releases id "com.github.spotbugs" version "2.0.0" apply false + //https://github.com/diffplug/goomph + id "com.diffplug.p2.asmaven" version "3.21.0" apply false // https://github.com/diffplug/spotless-changelog id "com.diffplug.spotless-changelog" version "1.1.0" apply false } @@ -34,7 +36,7 @@ spotless { } // root eclipse project -apply plugin: 'com.diffplug.gradle.eclipse.resourcefilters' +apply plugin: 'com.diffplug.eclipse.resourcefilters' eclipseResourceFilters { exclude().folders().name('.git') exclude().folders().name('build').recursive() diff --git a/gradle.properties b/gradle.properties index 025c89fbf9..ea5d528a40 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,9 @@ artifactIdGradle=spotless-plugin-gradle VER_JAVA=1.8 VER_SPOTBUGS=3.1.6 +# Dependencies provided by Spotless plugin +VER_SLF4J=[1.6,2.0[ + # Used in multiple places VER_DURIAN=1.2.0 VER_JUNIT=4.12 diff --git a/gradle/java-setup.gradle b/gradle/java-setup.gradle index 0d55295a9e..f0488ec346 100644 --- a/gradle/java-setup.gradle +++ b/gradle/java-setup.gradle @@ -23,7 +23,7 @@ eclipse { // always create fresh projects tasks.eclipse.dependsOn(cleanEclipse) -apply plugin: 'com.diffplug.gradle.eclipse.resourcefilters' +apply plugin: 'com.diffplug.eclipse.resourcefilters' eclipseResourceFilters { exclude().folders().name('build') } diff --git a/ide/build.gradle b/ide/build.gradle index 0a7877a231..0a5d2c560c 100644 --- a/ide/build.gradle +++ b/ide/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'com.diffplug.gradle.oomph.ide' +apply plugin: 'com.diffplug.oomph.ide' oomphIde { repoEclipseLatest() jdt {} diff --git a/settings.gradle b/settings.gradle index d610f5b89e..72f62e0ad6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -46,3 +46,25 @@ include 'plugin-gradle' // gradle-specific glue code if (System.getenv('SPOTLESS_EXCLUDE_MAVEN') != 'true' && System.getenv('JITPACK') != 'true') { include 'plugin-maven' // maven-specific glue code } + +def getStartProperty(java.lang.String name) { + def value = startParameter.getProjectProperties().get('com.diffplug.spotless.include.ext') + if(null != value) { + return value + } + // user properties are not available in the startParameter + def userPropertiesFile = new java.io.File(startParameter.getGradleUserHomeDir(), 'gradle.properties') + def userProperties = new java.util.Properties() + if (userPropertiesFile.exists()) { + userProperties.load(userPropertiesFile.newReader()) + } + return userProperties.get(name) +} + +// include external (_ext) projects from development builds +if (getStartProperty('com.diffplug.spotless.include_ext') == 'true') { + file('_ext').eachDirMatch(~/^(?!(\.|gradle)).*/) { dir -> + include dir.name + project(":${dir.name}").projectDir = dir + } +}