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

Gradle KTS integration #64

Closed mustafa-antonio closed 2 years ago

mustafa-antonio commented 2 years ago

Hello,

I couldn't find this issue here so I thought about writing new one. Is there a way to integrate this plugin with Gradle KTS syntax? cpd part was easy to set up but I don't know how to configure cpdCheck in Kotlin. Is this supported by this plugin or still in development? Some updated README would be nice.

Any kind of help or info is appreciated.

I'm using newest (3.3) version of this plugin.

All the best.

aaschmid commented 2 years ago

I am using it with KTS syntax in junit-dataprovider myself:

configure<de.aaschmid.gradle.plugins.cpd.CpdExtension> {
    // Use Java 8 and later to execute cpd successfully
    toolVersion = "6.13.0"
}

tasks.named<de.aaschmid.gradle.plugins.cpd.Cpd>("cpdCheck") {
    ignoreFailures = true
    minimumTokenCount = 25
    setSource(files(
            // only check java source code
            subprojects.flatMap { it.the<SourceSetContainer>()["main"].java.srcDirs },
            subprojects.flatMap { it.the<SourceSetContainer>()["test"].java.srcDirs }
    ))
}
mustafa-antonio commented 2 years ago

Thank you, will let you know how this works once I'm back to configuring CPD again this week.

mustafa-antonio commented 2 years ago

Sorry I've forgot to close this issue - thx for help!