-
Notifications
You must be signed in to change notification settings - Fork 467
spotlessApply and spotlessCheck in the same build fails in 4.x #581
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
Comments
Interesting! Here is the problem, and a quick workaround. Before Spotless 4.0, there was one task that did all the work, and In Spotless 4.0+, The thing is, running Making it an error is probably too opinionated. It seems that other people also want to run |
I think it is. Especially in a case where I explicitly invoke formatting task during the build. So my goals in this case - format sources and build them at the same time. I have spotlessApply task in "defaultTasks", so I invoke it in local builds, but I don't have it in CI/CD pipeline, so it just verifies formatting and fails if it's not formatted. This worked in version 3.30.0 at least. I wouldn't like spotless to format my sources auto-magically on every build(so CI fails if sources aren't formatted), but I'd like to get back possibility to run formatting if it's invoked explicitly without failing the build. |
@bigdaz interesting corner case we hadn't thought of in #576. It's not that uncommon for people to do I'm inclined to just use the taskgraph and make // if the user runs both, make sure that apply happens first,
// and then we don't need to run check since we know that apply just happened
checkTask.mustRunAfter(applyTask);
project.getGradle().getTaskGraph().whenReady(graph -> {
if (graph.hasTask(applyTask) && graph.hasTask(checkTask)) {
checkTask.setEnabled(false);
}
}); |
Fixed in |
I have this in my build.gradle.kts:
so I always run formatter before build. It worked up until version 4.0.0. Now plugin formats everything but fails at the end:
If I run build again - it passes, since everything was formatted previously.
It worked on gradle 6.4.1 and spotless gradle plugin 3.30.0.
The text was updated successfully, but these errors were encountered: