Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotless should use itself better #509

Merged
merged 7 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ This document is intended for Spotless developers.
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).

## [Unreleased]
### Changed
### Build
* All `CHANGES.md` are now in keepachangelog format. ([#507](https://github.com/diffplug/spotless/pull/507))
* We now use [javadoc.io](https://javadoc.io/) instead of github pages. ([#508](https://github.com/diffplug/spotless/pull/508))
* We no longer publish `-SNAPSHOT` for every build to `master`, since we have good [JitPack integration](https://github.com/diffplug/spotless/blob/master/CONTRIBUTING.md#gradle---any-commit-in-a-public-github-repo-this-one-or-any-fork). ([#508](https://github.com/diffplug/spotless/pull/508))
* Improved how we use Spotless on itself. ([#509](https://github.com/diffplug/spotless/pull/509))

## [1.27.0] - 2020-01-01
* Ignored `KtLintStepTest`, because [gradle/gradle#11752](https://github.com/gradle/gradle/issues/11752) is causing too many CI failures. ([#499](https://github.com/diffplug/spotless/pull/499))
Expand Down
10 changes: 10 additions & 0 deletions _ext/eclipse-wtp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
plugins {
id 'com.diffplug.gradle.spotless' version '3.27.0'
}
ext {
developers = [
fvgh: [ name: 'Frank Vennemeyer', email: '[email protected]' ],
Expand Down Expand Up @@ -118,3 +121,10 @@ fileTree(dir: testLocation).include('**/*Test.java').each { file ->
}
test.dependsOn "${testFile}"
}

spotless {
format 'xml', {
target 'src/main/resources/**/*.xml'
eclipseWtp('xml').configFile 'spotless.xmlformat.prefs'
}
}
File renamed without changes.
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ 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
// here
id 'com.diffplug.gradle.spotless' version '3.27.0'
}

// this is... not the canonical way to do spotless :)
allprojects {
apply from: rootProject.file('gradle/spotless.gradle')
}
apply from: rootProject.file('gradle/spotless-freshmark.gradle')

spotless {
format 'dotfiles', {
target '.gitignore', '.gitattributes', '.editorconfig'
indentWithSpaces(2)
trimTrailingWhitespace()
endWithNewline()
}
}

// root eclipse project
Expand Down
14 changes: 14 additions & 0 deletions gradle/spotless-freshmark.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
freshmark {
target '*.md'
propertiesFile(rootProject.file('gradle.properties'))
properties {
it.put('yes', ':+1:')
it.put('no', ':white_large_square:')
}
indentWithSpaces(2)
trimTrailingWhitespace()
endWithNewline()
}
}
File renamed without changes.
32 changes: 32 additions & 0 deletions gradle/spotless.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
def noInternalDepsClosure = {
String text = it
/*
* No good way to get around using this import:
* https://github.com/gradle/gradle/issues/3191
*/
String regex = "import org\\.gradle\\.api\\.internal\\.(?!plugins\\.DslObject)"
if ((text.contains('import org.gradle.internal.') || text.find(regex)) &&
!text.contains('def noInternalDepsClosure')) {
throw new AssertionError("Accidental internal import")
}
}
if (project.name != 'ide' && project != rootProject) {
// the rootProject and ide projects don't have any java
java {
custom 'noInternalDeps', noInternalDepsClosure
bumpThisNumberIfACustomStepChanges(1)
licenseHeaderFile rootProject.file('gradle/spotless.license')
importOrderFile rootProject.file('gradle/spotless.importorder')
eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml')
trimTrailingWhitespace()
removeUnusedImports()
}
}
groovyGradle {
target '*.gradle'
paddedCell()
greclipse().configFile rootProject.files('gradle/spotless.eclipseformat.xml', 'gradle/spotless.groovyformat.prefs')
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 11 additions & 15 deletions plugin-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ext.artifactId = project.artifactIdGradle
ext.version = project.versionGradle
apply from: rootProject.file('gradle/java-setup.gradle')
apply from: rootProject.file('gradle/java-publish.gradle')
apply from: rootProject.file('gradle/spotless-freshmark.gradle')

apply plugin: 'java-library'
apply plugin: 'com.gradle.plugin-publish'
Expand All @@ -28,24 +29,19 @@ dependencies {

tasks.eclipse.dependsOn(pluginUnderTestMetadata)

/////////////////////
// SPOTLESS (fake) //
/////////////////////
task spotlessCheck(type: JavaExec) {
classpath sourceSets.test.runtimeClasspath
main = 'com.diffplug.gradle.spotless.SelfTestCheck'
}
check.dependsOn(spotlessCheck)

task spotlessApply(type: JavaExec) {
classpath sourceSets.test.runtimeClasspath
main = 'com.diffplug.gradle.spotless.SelfTestApply'
}
test { testLogging.showStandardStreams = true }

test { useJUnit { excludeCategories 'com.diffplug.spotless.category.NpmTest' } }
test {
useJUnit {
excludeCategories 'com.diffplug.spotless.category.NpmTest'
}
}

task npmTest(type: Test) { useJUnit { includeCategories 'com.diffplug.spotless.category.NpmTest' } }
task npmTest(type: Test) {
useJUnit {
includeCategories 'com.diffplug.spotless.category.NpmTest'
}
}

//////////////////////////
// GRADLE PLUGIN PORTAL //
Expand Down
2 changes: 2 additions & 0 deletions plugin-maven/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
id 'cz.malohlava.visteg' version '1.0.5' // https://github.com/mmalohlava/gradle-visteg
}

apply from: rootProject.file('gradle/spotless-freshmark.gradle')

// to generate taskGraph.pdf
// - set enabled (below) to true
// - run: ./gradlew :plugin-maven:test
Expand Down
71 changes: 0 additions & 71 deletions spotlessSelf.gradle

This file was deleted.