adding PMD and CPD support

git-svn-id: http://google-refine.googlecode.com/svn/trunk@407 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-07 17:31:25 +00:00
parent 6dbe794658
commit 6674b69773
2 changed files with 96 additions and 8 deletions

View File

@ -29,6 +29,7 @@
<property name="tests.dir" value="${basedir}/tests/java" />
<property name="tools.dir" value="${basedir}/tools" />
<property name="reports.dir" value="${build.dir}/reports" />
<property name="server_classes.dir" value="${build.dir}/classes" />
<property name="webapp_classes.dir" value="${basedir}/src/main/webapp/WEB-INF/classes" />
<property name="tests_classes.dir" value="${tests.dir}/classes" />
@ -235,19 +236,63 @@
</tar>
</target>
<target name="findbugs" depends="build">
<target name="prepare_reports">
<mkdir dir="${reports.dir}" />
</target>
<target name="findbugs" depends="build,prepare_reports">
<taskdef
name="findbugs"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
classpath="${findbugs.dir}/lib/findbugs-ant.jar"
/>
<findbugs jvmargs="-Xmx1024m" home="${findbugs.dir}" output="html" outputFile="${build.dir}/gridworks-findbugs.html" >
<findbugs jvmargs="-Xmx1024m" home="${findbugs.dir}" output="html" outputFile="${reports.dir}/findbugs.html" >
<auxClasspath refid="class.path" />
<sourcePath path="${src.dir}" />
<class location="${webapp_classes.dir}" />
</findbugs>
</target>
<target name="pmd" depends="prepare_reports">
<path id="pmd.path">
<fileset dir="${pmd.dir}/lib" includes="*.jar"/>
</path>
<taskdef
name="pmd"
classname="net.sourceforge.pmd.ant.PMDTask"
classpathref="pmd.path"
/>
<pmd targetjdk="1.6" encoding="UTF-8">
<ruleset>basic</ruleset>
<formatter type="html" toFile="${reports.dir}/pmd.html" toConsole="true"/>
<fileset dir="${server.src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
<target name="cpd" depends="prepare_reports">
<path id="pmd.path">
<fileset dir="${pmd.dir}/lib" includes="*.jar"/>
</path>
<taskdef
name="cpd"
classname="net.sourceforge.pmd.cpd.CPDTask"
classpathref="pmd.path"
/>
<cpd minimumTokenCount="100" outputFile="${reports.dir}/cpd.txt" encoding="UTF-8">
<fileset dir="${server.src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</cpd>
</target>
<target name="clean">
<delete file="${build.dir}/gridworks.jar" />
<delete dir="${server_classes.dir}" />

View File

@ -53,15 +53,19 @@ where [options] include:
and <action> is one of
build ..................... Build Gridworks
run ....................... Run Gridworks
run ....................... Run Gridworks [default]
test ...................... Run all Gridworks tests
server_test ............... Run only the server tests
ui_test ................... Run only the UI tests
test ...................... Test Gridworks
findbugs .................. Run Findbugs against Gridworks
pmd ....................... Run PMD against Gridworks
cpd ....................... Run Copy/Paste Detection against Gridworks
mac_dist <version> ........ Make MacOSX binary distribution
windows_dist <version> .... Make Windows binary distribution
linux_dist <version> ...... Make Linux binary distribution
dist <version> ............ Make all distributions
clean ..................... Clean compiled classes
@ -96,6 +100,14 @@ check_downloaders() {
fi
}
check_unzip() {
UNZIP="`which unzip`"
if [ "$UNZIP" == "" ] ; then
error "We need 'unzip' present in PATH to expand external dependencies."
fi
}
check_python() {
PYTHON="`which python`"
if [ "$PYTHON" == "" ] ; then
@ -163,7 +175,12 @@ tool_download() {
download $URL $FILE
fi
if [ ! -d "$DIR" ] ; then
if [ `echo $FILE | sed 's|.*.(tar.gz|tgz)$||'` == "" ] ; then
tar xzf $FILE || error "Error while expanding $FILE"
elif [ `echo $FILE | sed 's|.*.zip$||'` == "" ] ; then
check_unzip
$UNZIP $FILE || error "Error while expanding $FILE"
fi
fi
cd ..
}
@ -280,6 +297,16 @@ findbugs_prepare() {
tool_download $FINDBUGS_URL $FINDBUGS_FILE $FINDBUGS_DIR
}
pmd_prepare() {
tools_prepare
PMD_URL="http://downloads.sourceforge.net/project/pmd/pmd/4.2.5/pmd-bin-4.2.5.zip"
PMD_FILE="pmd-bin-4.2.5.zip"
PMD_DIR="pmd-4.2.5"
tool_download $PMD_URL $PMD_FILE $PMD_DIR
}
# ----------------------------------------------------------------------------------------------
ant() {
@ -492,7 +519,7 @@ run() {
echo ""
if [ "$FORK" == "" ] ; then
exec "$RUN_CMD"
exec $RUN_CMD
else
sh -c "$RUN_CMD" &
GRIDWORKS_PID="$!"
@ -522,6 +549,20 @@ findbugs() {
ant findbugs
}
pmd() {
pmd_prepare
ANT_PARAMS="-Dpmd.dir=${GRIDWORKS_TOOLS_DIR}/${PMD_DIR}"
ant pmd
}
cpd() {
pmd_prepare
ANT_PARAMS="-Dpmd.dir=${GRIDWORKS_TOOLS_DIR}/${PMD_DIR}"
ant cpd
}
# -------------------------- script -----------------------------
# ----- Normalize the current directory -------------------------
@ -642,6 +683,8 @@ case "$ACTION" in
ui_test) ui_test $1;;
server_test) server_test $1;;
findbugs) findbugs;;
pmd) pmd;;
cpd) cpd;;
run) run;;
execute) execute $*;;
mac_dist) mac_dist $1;;