From 6e755b22f60819c0ff3ce6ef011d8745aaa9a80e Mon Sep 17 00:00:00 2001 From: Andreas Schmid Date: Sun, 27 Jan 2019 19:41:04 +0100 Subject: [PATCH] fix #28 by using new mechanism to set default pmd dependency Otherwise since Gradle 5.1. an UnsupportedOperationException is thrown while addint the default dependency the "old" way. Reason is not 100% clear but FindBugsPlugin uses this mechanism as well. --- .../groovy/de/aaschmid/gradle/plugins/cpd/CpdPlugin.groovy | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/de/aaschmid/gradle/plugins/cpd/CpdPlugin.groovy b/src/main/groovy/de/aaschmid/gradle/plugins/cpd/CpdPlugin.groovy index 9eb87ec..db40a6f 100644 --- a/src/main/groovy/de/aaschmid/gradle/plugins/cpd/CpdPlugin.groovy +++ b/src/main/groovy/de/aaschmid/gradle/plugins/cpd/CpdPlugin.groovy @@ -154,10 +154,9 @@ class CpdPlugin implements Plugin { Configuration configuration = project.configurations.create('cpd') configuration.with{ description = 'The CPD libraries to be used for this project.' - incoming.beforeResolve{ - if (dependencies.isEmpty()) { - dependencies.add(project.dependencies.create("net.sourceforge.pmd:pmd-dist:${extension.toolVersion}")) - } + + configuration.defaultDependencies{ d -> + d.add(project.getDependencies().create("net.sourceforge.pmd:pmd-dist:${extension.toolVersion}")) } transitive = true visible = false