Allow configuration of when to run spotless in gradle build
See original GitHub issueCurrently spotless adds itself automatically to the gradle checkTask.
// Add our check task as a dependency on the global check task
// getTasks() returns a "live" collection, so this works even if the
// task doesn't exist at the time this call is made
project.getTasks()
.matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME))
.all(task -> task.dependsOn(rootCheckTask));
We would like to be able to decide when to actually run the spotless task or even be able to only run it when directly invoked from the command line like gradlew spotless
e.g. for configuration
spotless {
...
}
// new
taskX.dependsOn spotless
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
spotless/README.md at main - plugin-gradle - GitHub
Spotless supports all of Gradle's built-in performance features (incremental build, ... spotless { java { // Use the default importOrder configuration ...
Read more >Running Spotless Automagically with Gradle - Jamie Tanna
I've got mine set up so with my Gradle projects, Spotless is enforced after the compilation phase ( JavaCompile ). The alternative, more ......
Read more >Gradle: Spotless task not firing when needed - Stack Overflow
Spotless ' intended behavior is to let you know that there's a problem with spotlessCheck . Then you run spotlessApply yourself manually.
Read more >Improve code formatting on every commit - Medium
Running the build after integrating spotless will point out violations in code based on the rules that we specify inside the spotless task....
Read more >Using a Code Formatter - WPILib Docs
Configuration . Necessary build.gradle changes are required to get Spotless functional. In the plugins {} block of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
as a matter of fact you are totally right both in “when the task is called” and in the statement that spotless is much faster 😉
Here’s gradle’s task dependency graph:
If you’d like to just compile and package, run
assemble
. If you just want to run tests, runtest
(orintegTest
if you’ve made a separate unit test task).The objective of the
check
task is (according to the gradle docs):You can use Gradle however you’d like, but it sounds like you’re swimming upstream 😃 If you want people to always be able to run
gradle build
and have it be fast, I’d recommend that you instead print out the task graph above and leave it on their desk, and then they’ll know which tasks to run for themselves, depending on how fast they’d like their result.Also, spotless is much faster than a reasonable unit test suite 😃