aaschmid / gradle-cpd-plugin

Gradle plugin to find duplicate code using PMDs copy/paste detection (= CPD).
Apache License 2.0
96 stars 12 forks source link

unable to find cpdCheck in subProject. #65

Closed mysticdrew closed 1 year ago

mysticdrew commented 1 year ago

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.

aaschmid commented 1 year ago

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.

aaschmid commented 1 year ago

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