Use PMD's Copy/Paste Detector with Gradle

Viewed 2595

I'd like to use Copy/Paste Detector in my Gradle build.

This is why I've decided to translate the following Ant task (which I've found here) into Gradle syntax:

<target name="cpd">
    <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" />
    <cpd minimumTokenCount="100" outputFile="/home/tom/cpd.txt">
        <fileset dir="/home/tom/tmp/ant">
            <include name="**/*.java"/>
        </fileset>
    </cpd>
</target>

This is how the translation looks currently:

check << {
        ant.taskdef(name: 'cpd', classname: 'net.sourceforge.pmd.cpd.CPDTask', classpath: configurations.pmd.asPath)
        ant.cpd(minimumTokenCount: '100', outputFile: file('build/reports/pmd/copyPasteDetector.txt').toURI().toString()) {
            fileset(dir: 'src'){
                include(name: '**.java')
        }
    }
}

Unfortunately calling gradle check yields an net.sourceforge.pmd.cpd.ReportException, the stacktrace is here.

How can I scan my source code with the Copy/Paste Detector using Gradle 1.9?

Thanks!

3 Answers
Related