-
Notifications
You must be signed in to change notification settings - Fork 459
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
Concurrency issue when using GradleBuild task in multiproject setup #1087
Comments
I think I know why this is happening. We create a single task in the root project, The way that we resolved that was:
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessExtension.java Lines 242 to 252 in 804a73a
The exception being caught above is thrown on this line: spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessExtension.java Line 259 in 804a73a
I think I have an easy solution (I feel like there's an air bubble of "Gradle demands to declare dependencies in the root project" and Spotless is pushing that bubble around, but we do seem to have concretely ironed out some cases, and here we can iron out another. |
I was wrong. I added some very simple printlns: 72919ce And this is the output I get over and over:
The important thing is that "FAILED TO REGISTER" is never printed, and it is strange that "REGISTER" succeeds twice. Not sure what to make of that... |
You probably also already noticed this, but it's not even necessary to run any Spotless tasks: |
This seems like a Gradle bug to me. I wonder if something as simple as this could reproduce it: public class BugPlugin implements Plugin<Project> {
static final String BUG_TASK = "bug";
TaskProvider<BugTask> bugTask;
@Override
public void apply(Project project) {
if (!project.rootProject.tasks.names.contains(BUG_TASK)) {
bugTask = rootProjectTasks.register(BUG_TASK, BugTask.class, BugTask::setup);
} else {
bugTask = rootProjectTasks.named(BUG_TASK, BugTask.class);
}
} |
It could certainly be a Gradle bug, would be good to rule out Spotless from the equation. |
I tried with subprojects {
if (!project.rootProject.tasks.names.contains("dummy")) {
project.rootProject.tasks.register("dummy", DefaultTask::class.java)
} else {
println("contains dummy")
}
} which should be the equivalent of applying the plugin, but it didn't provoke any issue. Looking at the debug logs when using the Spotless plugin, it looks like Gradle registers one |
The fact that there's a reference to the |
Maybe instead of
I agree that seems to be the case, but I don't understand why that is happening / is possible. Seems like a very bad design to have "which project is the root" depend on the context of how it was called. |
I also faced the same bug, I cannot help you much but it would be great if you could solve it ! |
fwiw, we are now seeing this as well in gradle 7.4.2 (I know, I know...) |
We've made huge changes in |
JavaCompile
tasks can fail randomly if the Spotless plugin is applied on subprojects AND aGradleBuild
task is executing on the same project in parallel.Gradle version 7.3.3
Spotless Gradle plugin version 6.1.2
Gradle build scan: https://gradle.com/s/enf5wof4kfw7i
Public repo: https://github.com/davidburstromspotify/spotless-issue-1087
I have a feeling the plugin causes some cross talk between the outer and inner build.
The text was updated successfully, but these errors were encountered: