Skip to content

activate removeWildcardImports() #2526

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
30 changes: 15 additions & 15 deletions gradle/spotless.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
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")
}
}
// the rootProject doesn't have any java
if (project != rootProject) {
// the rootProject doesn't have any java
java {
ratchetFrom 'origin/main'
bumpThisNumberIfACustomStepChanges(1)
Expand All @@ -22,8 +10,20 @@ spotless {
eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml')
trimTrailingWhitespace()
removeUnusedImports()
// TODO: formatAnnotations()
custom 'noInternalDeps', noInternalDepsClosure
removeWildcardImports()
formatAnnotations()
custom 'noInternalDeps', {
/*
* No good way to get around using this import:
* https://github.com/gradle/gradle/issues/3191
*/
var regex = "import org\\.gradle\\.api\\.internal\\.(?!plugins\\.DslObject)(?!project\\.ProjectInternal)"
if (it.contains('import org.gradle.internal.')
|| it.find(regex as Closure)
&& !it.contains('def noInternalDepsClosure')) {
throw new AssertionError("Accidental internal import")
}
}
}
}
groovyGradle {
Expand Down
Loading