Skip to content

Commit bb87b2e

Browse files
authored
Merge pull request #509 from diffplug/feat/better-self-apply
Spotless should use itself better
2 parents cf7602c + 58fe42e commit bb87b2e

13 files changed

+88
-87
lines changed

Diff for: CHANGES.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ This document is intended for Spotless developers.
1010
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
1111

1212
## [Unreleased]
13-
### Changed
13+
### Build
1414
* All `CHANGES.md` are now in keepachangelog format. ([#507](https://github.com/diffplug/spotless/pull/507))
1515
* We now use [javadoc.io](https://javadoc.io/) instead of github pages. ([#508](https://github.com/diffplug/spotless/pull/508))
1616
* 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))
17+
* Improved how we use Spotless on itself. ([#509](https://github.com/diffplug/spotless/pull/509))
1718

1819
## [1.27.0] - 2020-01-01
1920
* 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))

Diff for: _ext/eclipse-wtp/build.gradle

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
plugins {
2+
id 'com.diffplug.gradle.spotless' version '3.27.0'
3+
}
14
ext {
25
developers = [
36
fvgh: [ name: 'Frank Vennemeyer', email: '[email protected]' ],
@@ -118,3 +121,10 @@ fileTree(dir: testLocation).include('**/*Test.java').each { file ->
118121
}
119122
test.dependsOn "${testFile}"
120123
}
124+
125+
spotless {
126+
format 'xml', {
127+
target 'src/main/resources/**/*.xml'
128+
eclipseWtp('xml').configFile 'spotless.xmlformat.prefs'
129+
}
130+
}
File renamed without changes.

Diff for: build.gradle

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ plugins {
1111
id 'org.jdrupes.mdoclet' version '1.0.5' apply false
1212
// https://github.com/spotbugs/spotbugs/releases
1313
id "com.github.spotbugs" version "2.0.0" apply false
14+
// here
15+
id 'com.diffplug.gradle.spotless' version '3.27.0'
16+
}
17+
18+
// this is... not the canonical way to do spotless :)
19+
allprojects {
20+
apply from: rootProject.file('gradle/spotless.gradle')
21+
}
22+
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
23+
24+
spotless {
25+
format 'dotfiles', {
26+
target '.gitignore', '.gitattributes', '.editorconfig'
27+
indentWithSpaces(2)
28+
trimTrailingWhitespace()
29+
endWithNewline()
30+
}
1431
}
1532

1633
// root eclipse project

Diff for: gradle/spotless-freshmark.gradle

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apply plugin: 'com.diffplug.gradle.spotless'
2+
spotless {
3+
freshmark {
4+
target '*.md'
5+
propertiesFile(rootProject.file('gradle.properties'))
6+
properties {
7+
it.put('yes', ':+1:')
8+
it.put('no', ':white_large_square:')
9+
}
10+
indentWithSpaces(2)
11+
trimTrailingWhitespace()
12+
endWithNewline()
13+
}
14+
}
File renamed without changes.

Diff for: gradle/spotless.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.diffplug.gradle.spotless'
2+
spotless {
3+
def noInternalDepsClosure = {
4+
String text = it
5+
/*
6+
* No good way to get around using this import:
7+
* https://github.com/gradle/gradle/issues/3191
8+
*/
9+
String regex = "import org\\.gradle\\.api\\.internal\\.(?!plugins\\.DslObject)"
10+
if ((text.contains('import org.gradle.internal.') || text.find(regex)) &&
11+
!text.contains('def noInternalDepsClosure')) {
12+
throw new AssertionError("Accidental internal import")
13+
}
14+
}
15+
if (project.name != 'ide' && project != rootProject) {
16+
// the rootProject and ide projects don't have any java
17+
java {
18+
custom 'noInternalDeps', noInternalDepsClosure
19+
bumpThisNumberIfACustomStepChanges(1)
20+
licenseHeaderFile rootProject.file('gradle/spotless.license')
21+
importOrderFile rootProject.file('gradle/spotless.importorder')
22+
eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml')
23+
trimTrailingWhitespace()
24+
removeUnusedImports()
25+
}
26+
}
27+
groovyGradle {
28+
target '*.gradle'
29+
paddedCell()
30+
greclipse().configFile rootProject.files('gradle/spotless.eclipseformat.xml', 'gradle/spotless.groovyformat.prefs')
31+
}
32+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: plugin-gradle/build.gradle

+11-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ext.artifactId = project.artifactIdGradle
22
ext.version = project.versionGradle
33
apply from: rootProject.file('gradle/java-setup.gradle')
44
apply from: rootProject.file('gradle/java-publish.gradle')
5+
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
56

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

2930
tasks.eclipse.dependsOn(pluginUnderTestMetadata)
3031

31-
/////////////////////
32-
// SPOTLESS (fake) //
33-
/////////////////////
34-
task spotlessCheck(type: JavaExec) {
35-
classpath sourceSets.test.runtimeClasspath
36-
main = 'com.diffplug.gradle.spotless.SelfTestCheck'
37-
}
38-
check.dependsOn(spotlessCheck)
39-
40-
task spotlessApply(type: JavaExec) {
41-
classpath sourceSets.test.runtimeClasspath
42-
main = 'com.diffplug.gradle.spotless.SelfTestApply'
43-
}
4432
test { testLogging.showStandardStreams = true }
4533

46-
test { useJUnit { excludeCategories 'com.diffplug.spotless.category.NpmTest' } }
34+
test {
35+
useJUnit {
36+
excludeCategories 'com.diffplug.spotless.category.NpmTest'
37+
}
38+
}
4739

48-
task npmTest(type: Test) { useJUnit { includeCategories 'com.diffplug.spotless.category.NpmTest' } }
40+
task npmTest(type: Test) {
41+
useJUnit {
42+
includeCategories 'com.diffplug.spotless.category.NpmTest'
43+
}
44+
}
4945

5046
//////////////////////////
5147
// GRADLE PLUGIN PORTAL //

Diff for: plugin-maven/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ plugins {
66
id 'cz.malohlava.visteg' version '1.0.5' // https://github.com/mmalohlava/gradle-visteg
77
}
88

9+
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
10+
911
// to generate taskGraph.pdf
1012
// - set enabled (below) to true
1113
// - run: ./gradlew :plugin-maven:test

Diff for: spotlessSelf.gradle

-71
This file was deleted.

0 commit comments

Comments
 (0)