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

spotlessCheck not run as part of a gradle build #1164

Closed
5 tasks done
AlecKazakova opened this issue Apr 9, 2022 · 8 comments
Closed
5 tasks done

spotlessCheck not run as part of a gradle build #1164

AlecKazakova opened this issue Apr 9, 2022 · 8 comments

Comments

@AlecKazakova
Copy link

  • summary of problem:
    The spotlessCheck task is no longer run as part of a build execution. Confirmed by running ./gradlew build --dry-run. The spotlessCheck task still exists and can be run manually.
  • gradle or maven version: 7.4.2
  • spotless version: 6.4.2
  • operating system and version: multiple (running on linux/mac/windows on CI)
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible: repo, with this main config in root build.gradle
spotless {
  kotlin {
    target "**/*.kt"
    targetExclude "**/gen/**/*.*", "**/generated/**/*.*", "sqldelight-compiler/integration-tests/src/test/kotlin/com/example/**/*.*", "sqldelight-compiler/src/test/migration-interface-fixtures/**/*.*"
    ktlint(deps.versions.ktlint.get()).userData(["indent_size": "2"])
    trimTrailingWhitespace()
    endWithNewline()
  }
}
@nedtwigg
Copy link
Member

nedtwigg commented Apr 9, 2022

I think the chain is build -> check -> spotlessCheck.

The build and check tasks are setup by the base plugin, which Spotless used to apply itself, but we stopped because that caused some conflict with the Android plugin.

Are you sure that your project has a build or check task? You can get them by applying base.

@AlecKazakova
Copy link
Author

yea build and check are both still there (via running ./gradlew tasks). I can confirm though that applying base fixes this problem and the spotless tasks are added to the task dependencies

@nedtwigg
Copy link
Member

Based on https://github.com/cashapp/sqldelight/blob/master/build.gradle, I suspect that your root project actually does not have a build or check task (unless someone applies base), and ./gradlew tasks is showing you the tasks of the subprojects, not the root project.

But this feels like Spotless should just always apply base. That's what we did until December 2021 in 6.0.3 when we stopped (#1014) mostly just because some Android template manually created a clean task which interfered with any plugin that relied on the conventions in base, but Google has since fixed that, so I think we probably made a mistake by adapting to their bug.

You can fix this by applying base, but I'm inclined to make Spotless eagerly apply base itself in a future release unless someone talks me out of it before then.

@jbduncan
Copy link
Member

I'm working on an Android project that still uses the clean task generated by the old version of the Android template.

So the only thing I'd encourage is to add some instructions to the release notes on how to adapt any existing, custom clean tasks.

It's probably just a matter of changing any such tasks to something like:

tasks.named<Delete>("clean") {
    . . .
}

...as opposed to tasks.registering, which is what we're using.

We're using the Gradle Kotlin DSL in our project, so I'd need to dive into our VCS history or crack open an old version of Android Studio to remind myself what the Groovy syntax is.

(Having said all this, it's worth noting that we don't use Spotless... yet? 😁)

@AlecKazakova
Copy link
Author

👍 sounds good, thanks. I'll apply base for now and remove it in a future spotless release

@nedtwigg
Copy link
Member

Base is now applied eagerly starting with plugin-gradle 6.5.0.

@AlecKazakova
Copy link
Author

confirmed fixed, thanks 👍

@ColtonIdle
Copy link

Nice. I think this was my fault for originally bringing it up with the spotless team, but it led me to file a bug with the Android team, and they removed it from their template. https://issuetracker.google.com/issues/186924459

All's well that ends well.

Thanks spotless team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants