Skip to content

Instantly share code, notes, and snippets.

@yangboz
Created October 23, 2012 06:53
Show Gist options
  • Save yangboz/6730172507a5c8dea0f3 to your computer and use it in GitHub Desktop.
Save yangboz/6730172507a5c8dea0f3 to your computer and use it in GitHub Desktop.
Ant xml example for JAVA code CPD.
<?xml version="1.0"?>
<project name="XXX Application Build with CPD" default="run"
basedir="../">
<description>
Ant build sample for running
- CPD,
</description>
<!-- Change the paths to your individual installation directories -->
<property name="cpd.home.dir" location="${basedir}/tools/cpd/" />
<property name="lib.dir" location="${basedir}/map/lib" />
<property name="src.dir" location="${basedir}/map/app/" />
<property name="bin.dir" location="${basedir}/bin" />
<property name="htm.dir" location="${basedir}/html" />
<property name="report.dir" location="${basedir}/report" />
<property name="report.cpd.dir" location="${report.dir}/cpd" />
<!-- Task of clean -->
<target name="clean" description="Delete all result to start with a clean build.">
<delete dir="${report.cpd.dir}" />
<delete dir="${report.temp.dir}" />
<delete dir="${bin.dir}" />
</target>
<!-- Task of prepare report -->
<target name="prepare.report.dir" description="Prepares the reports folder">
<mkdir dir="${report.cpd.dir}" />
</target>
<!-- -->
<path id="cpd.classpath">
<pathelement location="${build}" />
<fileset dir="${cpd.home.dir}/lib/">
<include name="*.jar" />
</fileset>
</path>
<!-- Task of CPD -->
<target name="cpd">
<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask"
classpathref="cpd.classpath" />
<cpd minimumTokenCount="100" format="xml" language="java"
ignoreIdentifiers="true" ignoreLiterals="true"
outputFile="${report.cpd.dir}/cpd_report.xml">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
</cpd>
</target>
<!-- -->
<target name="run" description="Run the build" depends="clean,prepare.report.dir,cpd">
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment