subversion + checkstyle
#!/bin/bash
SVNLOOK=/usr/local/subversion/bin/svnlook
CHECKSTYLE=/home/checkstyle-5.1/checkstyle-all-5.1.jar
CHECKSTYLE_CONFIG=/home/test/aa/checkstyle.xml
REPOS="$1"
TXN="$2"
TMPDIR=/tmp/projects
REPORT=/tmp/projects/report
CHANGED=`$SVNLOOK changed -t "$TXN" "$REPOS" |grep -v "^D" |awk '{print $2}'`
echo $CHANGED >>/dev/stderr
for LINE in $CHANGED ; do
JAVAFILE=`echo $LINE | egrep \\.java$`
$SVNLOOK cat $REPOS -t $TXN $JAVAFILE >$TMPDIR/checkstyle.java
java -jar $CHECKSTYLE -c $CHECKSTYLE_CONFIG $TMPDIR/checkstyle.java >$TMPDIR/checkstyle.out
cat $TMPDIR/checkstyle.out | grep -v "^Starting audit...$\|^Audit done.$" | sed -e "s@$TMPDIR/checkstyle.java@$JAVAFILE@" >>$REPORT
done
WAR=`cat $REPORT|grep warning`
ERR=`cat $REPORT|grep -v warning`
if [ -z $ERR ] ;then
cat $REPORT > /dev/stderr
rm -Rf $TMPDIR/*
exit 0
else
cat $REPORT > /dev/stderr
rm -Rf $TMPDIR/*
exit 1
fi
SVNLOOK=/usr/local/subversion/bin/svnlook
CHECKSTYLE=/home/checkstyle-5.1/checkstyle-all-5.1.jar
CHECKSTYLE_CONFIG=/home/test/aa/checkstyle.xml
REPOS="$1"
TXN="$2"
TMPDIR=/tmp/projects
REPORT=/tmp/projects/report
CHANGED=`$SVNLOOK changed -t "$TXN" "$REPOS" |grep -v "^D" |awk '{print $2}'`
echo $CHANGED >>/dev/stderr
for LINE in $CHANGED ; do
JAVAFILE=`echo $LINE | egrep \\.java$`
$SVNLOOK cat $REPOS -t $TXN $JAVAFILE >$TMPDIR/checkstyle.java
java -jar $CHECKSTYLE -c $CHECKSTYLE_CONFIG $TMPDIR/checkstyle.java >$TMPDIR/checkstyle.out
cat $TMPDIR/checkstyle.out | grep -v "^Starting audit...$\|^Audit done.$" | sed -e "s@$TMPDIR/checkstyle.java@$JAVAFILE@" >>$REPORT
done
WAR=`cat $REPORT|grep warning`
ERR=`cat $REPORT|grep -v warning`
if [ -z $ERR ] ;then
cat $REPORT > /dev/stderr
rm -Rf $TMPDIR/*
exit 0
else
cat $REPORT > /dev/stderr
rm -Rf $TMPDIR/*
exit 1
fi