From 67fc9d8b4060379b0bfa7e995179bddfdcd64477 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 1 Jan 2020 14:23:54 -0800 Subject: [PATCH] Remove the #372 workaround, since we don't need it anymore. --- .../gradle/spotless/GradleProvisioner.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) 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 d5bbf6a823..218dfb2a2f 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 @@ -26,11 +26,9 @@ 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.Preconditions; -import com.diffplug.common.base.StringPrinter; import com.diffplug.common.collect.ImmutableList; import com.diffplug.spotless.Provisioner; @@ -39,6 +37,7 @@ public class GradleProvisioner { private GradleProvisioner() {} public static Provisioner fromProject(Project project) { + // TODO: this method is not necessary - we could remove it entirely for a small speedup return project.getPlugins().apply(SpotlessPlugin.class).getExtension().registerDependenciesTask.rootProvisioner; } @@ -74,21 +73,15 @@ static Provisioner fromRootBuildscript(Project project) { .map(project.getBuildscript().getDependencies()::create) .toArray(Dependency[]::new); - // #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); + Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration(deps); config.setDescription(mavenCoords.toString()); config.setTransitive(withTransitives); return config.resolve(); } catch (Exception e) { - logger.log(Level.SEVERE, - StringPrinter.buildStringFromLines("You probably need to add a repository containing the '" + mavenCoords + "' artifact in the 'build.gradle' of your root project.", + logger.log( + Level.SEVERE, + "You probably need to add a repository containing the '" + mavenCoords + "' artifact in the 'build.gradle' of your root project.\n" + "E.g.: 'buildscript { repositories { mavenCentral() }}'", - "Note that included buildscripts (using 'apply from') do not share their buildscript repositories with the underlying project.", - "You have to specify the missing repository explicitly in the buildscript of the root project."), e); throw e; }