From bdb3666b71cddd012076acb26fcda07d30cf7778 Mon Sep 17 00:00:00 2001 From: Staffan Forsell Date: Thu, 28 Mar 2019 07:38:07 +0100 Subject: [PATCH 1/2] #372 Synchronize access to rootProject.configurations to get around that rootProject.configurations.classpath is created in a non thread-safe way --- .../com/diffplug/gradle/spotless/GradleProvisioner.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java index 1e902f881f..57ee601de9 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java @@ -21,6 +21,7 @@ import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.ConfigurationContainer; import org.gradle.api.artifacts.Dependency; import com.diffplug.common.base.StringPrinter; @@ -37,7 +38,13 @@ public static Provisioner fromProject(Project project) { Dependency[] deps = mavenCoords.stream() .map(project.getBuildscript().getDependencies()::create) .toArray(Dependency[]::new); - Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration(deps); + + // #372 workaround: Accessing rootProject.configurations from multiple projects is not thread-safe + ConfigurationContainer configContainer; + synchronized (project.getRootProject()) { + configContainer = project.getRootProject().getBuildscript().getConfigurations(); + } + Configuration config = configContainer.detachedConfiguration(deps); config.setDescription(mavenCoords.toString()); config.setTransitive(withTransitives); return config.resolve(); From ee619f54f0d2c6febf70c734fde38d7fa89ab8e6 Mon Sep 17 00:00:00 2001 From: Staffan Forsell Date: Thu, 28 Mar 2019 13:50:28 +0100 Subject: [PATCH 2/2] Update CHANGES.md --- plugin-gradle/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index c6fabb92e4..13db3f9629 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -3,8 +3,8 @@ ### Version 3.21.0-SNAPSHOT - TBD ([javadoc](https://diffplug.github.io/spotless/javadoc/snapshot/), [snapshot](https://oss.sonatype.org/content/repositories/snapshots/com/diffplug/spotless/spotless-plugin-gradle/)) * Updated default eclipse-wtp from 4.7.3b to 4.8.0 ([#382](https://github.com/diffplug/spotless/pull/382)). * Updated default eclipse-groovy from 4.8.1 to 4.10.0 ([#382](https://github.com/diffplug/spotless/pull/382)). - * Updated default eclipse-jdt from 4.10.0 to 4.11.0 ([#384](https://github.com/diffplug/spotless/pull/384)) +* Fix intermittent error in multi-project builds ([#372](https://github.com/diffplug/spotless/issues/372)) ### Version 3.20.0 - March 11th 2019 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-plugin-gradle/3.20.0/), [jcenter](https://bintray.com/diffplug/opensource/spotless-plugin-gradle/3.20.0))