Skip to content

Commit 9dc5b8b

Browse files
author
Vincent Potucek
committed
activate removeWildcardImports()
1 parent 922f9f1 commit 9dc5b8b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

gradle/spotless.gradle

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
apply plugin: 'com.diffplug.spotless'
22
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)(?!project\\.ProjectInternal)"
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-
}
3+
// the rootProject doesn't have any java
154
if (project != rootProject) {
16-
// the rootProject doesn't have any java
175
java {
186
ratchetFrom 'origin/main'
197
bumpThisNumberIfACustomStepChanges(1)
@@ -22,8 +10,20 @@ spotless {
2210
eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml')
2311
trimTrailingWhitespace()
2412
removeUnusedImports()
25-
// TODO: formatAnnotations()
26-
custom 'noInternalDeps', noInternalDepsClosure
13+
removeWildcardImports()
14+
formatAnnotations()
15+
custom 'noInternalDeps', {
16+
/*
17+
* No good way to get around using this import:
18+
* https://github.com/gradle/gradle/issues/3191
19+
*/
20+
var regex = "import org\\.gradle\\.api\\.internal\\.(?!plugins\\.DslObject)(?!project\\.ProjectInternal)"
21+
if (it.contains('import org.gradle.internal.')
22+
|| it.find(regex as Closure)
23+
&& !it.contains('def noInternalDepsClosure')) {
24+
throw new AssertionError("Accidental internal import")
25+
}
26+
}
2727
}
2828
}
2929
groovyGradle {

0 commit comments

Comments
 (0)