From 80b6e3019679b0b99a0db9895209ce663a3a4ca2 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 3 Jul 2017 10:29:57 +0200 Subject: [PATCH] build.gradle: Do not resolve runtime configuration to early as it would cause "Cannot change dependencies of configuration after it has been included in dependency resolution" errors with Gradle >= 3. Thanks to James Justinic for pointing this out. --- build.gradle | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 716728794..6d1cceb7f 100644 --- a/build.gradle +++ b/build.gradle @@ -245,11 +245,18 @@ task distributionZip(type: Zip, dependsOn: [javadocAll, prepareReleasedocs, mark task maybeCheckForSnapshotDependencies { // Don't check for Snapshot dependencies if this is a snapshot. - if (isSnapshot) return - allprojects { project -> - project.configurations.runtime.each { - if (it.toString().contains("-SNAPSHOT")) - throw new Exception("Release build contains snapshot dependencies: " + it) + onlyIf { isReleaseVersion } + // Run in the execution phase, not in configuration phase, as the + // 'each' forces the runtime configuration to be resovled, which + // causes "Cannot change dependencies of configuration after it + // has been included in dependency resolution." errors. + // See https://discuss.gradle.org/t/23153 + doLast { + allprojects { project -> + project.configurations.runtime.each { + if (it.toString().contains("-SNAPSHOT")) + throw new Exception("Release build contains snapshot dependencies: " + it) + } } } }