question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow configuration of when to run spotless in gradle build

See original GitHub issue

Currently 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:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
simschlacommented, Jun 6, 2016

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 😉

0reactions
nedtwiggcommented, Jun 6, 2016

Here’s gradle’s task dependency graph:

image

If you’d like to just compile and package, run assemble. If you just want to run tests, run test (or integTest if you’ve made a separate unit test task).

The objective of the check task is (according to the gradle docs):

All verification tasks in the project, including test. Some plugins add additional verification tasks to the project.

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found