-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy pathspotless.gradle
33 lines (33 loc) · 1.15 KB
/
spotless.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
apply plugin: 'com.diffplug.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)(?!project\\.ProjectInternal)"
if ((text.contains('import org.gradle.internal.') || text.find(regex)) &&
!text.contains('def noInternalDepsClosure')) {
throw new AssertionError("Accidental internal import")
}
}
if (project != rootProject) {
// the rootProject doesn't have any java
java {
ratchetFrom 'origin/main'
bumpThisNumberIfACustomStepChanges(1)
licenseHeaderFile rootProject.file('gradle/spotless.license')
importOrderFile rootProject.file('gradle/spotless.importorder')
eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml')
trimTrailingWhitespace()
removeUnusedImports()
// TODO: formatAnnotations()
custom 'noInternalDeps', noInternalDepsClosure
}
}
groovyGradle {
target '*.gradle'
greclipse().configFile rootProject.files('gradle/spotless.eclipseformat.xml', 'gradle/spotless.groovyformat.prefs')
}
}