aaschmid/gradle-cpd-plugin

unable to find cpdCheck in subProject.

mysticdrew opened this issue · 2 comments

I am in the process of updating our gradle from 3.5.1 to 7.5.1. I have run into this issue on our multimodule projects. Works fine on our single module projects.

Snipit from build.gradle

plugins {
    id "de.aaschmid.cpd" version "3.3"
}

apply plugin: 'idea'
apply plugin: 'java'
......
subprojects {
    apply plugin: 'java'
    check.dependsOn cpdCheck
}

project(":services") {
  apply from: "${rootDir}/gradle-shared/java-library.gradle"
}

java-library.gradle

apply plugin: 'java'
apply plugin: 'pmd'

cpdCheck {
  ignoreFailures = true
  ignoreLiterals = true
  source = sourceSets.main.allJava
}
check.dependsOn cpdCheck

error

Could not find method cpdCheck() for arguments [java_library_cafaflm8mss6w23bqztti9kxy$_run_closure1@35898229] on project ':services' of type org.gradle.api.Project.

Could you try something like rootProject.cpdCheck. The CPD plugin is only applied to the rootProject such that it looks like that Gradle does not find the cpdCheck task any more. I guess this is due to a change of the internal behavior of task resolution coming with version 7 - but I might to check the release notes 🙊.

Edit: Maybe you need to find the task using the rootProject.tasks TaskContainer, see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.TaskContainer.html.

Closing due to no further information. Don't hesitate to reopen, though...