aaschmid / gradle-cpd-plugin

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

Warnings for other subprojects when building just one subproject #53

Open C-Otto opened 4 years ago

C-Otto commented 4 years ago

When building a single subproject ./gradlew aaa:build I get the following warning for each subproject, aside from the one I'm building. I expect to only receive warnings related to subproject aaa.

WARNING: Due to the absence of 'LifecycleBasePlugin' on project ':bbb' the task ':cpdCheck' could not be added to task graph. Therefore CPD will not be executed. To prevent this, manually add a task dependency of ':cpdCheck' to a 'check' task of a subproject.
1) Directly to project ':aaa':
    check.dependsOn(':cpdCheck')
2) Indirectly, e.g. via project ':bbb:
    project(':aaa') {
        plugins.withType(LifecycleBasePlugin) { // <- just required if 'java' plugin is applied within subproject
            check.dependsOn(cpdCheck)
        }
    }

I'm using Gradle 6.6 RC2. Some relevant parts of my build.gradle (in root project):

plugins {
    id 'de.aaschmid.cpd' version '3.1' apply false
}
evaluationDependsOnChildren()

configure(subprojects.findAll { it.name != 'xxx' }) {
    apply plugin: 'java'
    apply plugin: 'de.aaschmid.cpd'

    check.dependsOn(cpdCheck)

    cpdCheck {
        source = sourceSets.main.allJava // do not run for test code
    }
}
aaschmid commented 4 years ago

The error is logged in CpdPlugin here and the problem is that I check if the cpdCheck task is on the task graph for every project on which cpd plugin is applied ...

So I need to change this check. The question is how as I can always think of situations where this warning is either false positive or false negative :-( E.g. if looking for project's check task graph, one could want it on build.

Maybe I will remove this entirely and make it more prominent in the documentation.

If anyone has some hints / points on it, I would be very grateful hearing them.

C-Otto commented 4 years ago

In my understanding you want to log a helpful message to tell the user about a configuration issue (missing dependsOn?). If this is correct, I suggest to just drop this altogether. Instead, provide some documentation/examples, and maybe add a few examples that can be used to test the plugin.

C-Otto commented 3 years ago

This is creating lots of output when running gradle in continuous mode, to the point that I had to disable the plugin.

Lucas3oo commented 3 years ago

+1 this bug is super annoying