Merge lp:~trond-norbye/gearman-java/checkstyle_support into lp:gearman-java

Proposed by Trond Norbye
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trond-norbye/gearman-java/checkstyle_support
Merge into: lp:gearman-java
Diff against target: None lines
To merge this branch: bzr merge lp:~trond-norbye/gearman-java/checkstyle_support
Reviewer Review Type Date Requested Status
Gearman-developers Pending
Review via email: mp+9714@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Trond Norbye (trond-norbye) wrote :

Added support for running checkstyle on the code ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build.xml'
2--- build.xml 2009-07-16 23:40:07 +0000
3+++ build.xml 2009-08-05 19:26:15 +0000
4@@ -11,6 +11,10 @@
5 <property name="dist.docs.dir" location="${dist.dir}/docs" />
6 <property name="dist.jar" location="${dist.lib.dir}/${ant.project.name}-${project.version}.jar"/>
7 <property name="api.pkg" value="org.gearman"/>
8+ <property name="pmd.home" value="${user.home}/.ant/lib/pmd"/>
9+ <property name="findbugs.home" value="${user.home}/.ant/lib/findbugs"/>
10+ <property name="checkstyle.home" value="${user.home}/.ant/lib/checkstyle"/>
11+
12 <path id="build.classpath">
13 <pathelement location="${build.classes.dir}" />
14 </path>
15@@ -20,6 +24,87 @@
16 <pathelement location="${junit.jar}" />
17 </path>
18
19+ <path id="pmd.lib.search.path">
20+ <pathelement path="${pmd.home}/lib/"/>
21+ <pathelement path="${java.class.path}"/>
22+ <pathelement path="lib/pmd/lib/"/>
23+ </path>
24+
25+ <path id="findbugs.lib.search.path">
26+ <pathelement path="${findbugs.home}/lib/"/>
27+ <pathelement path="${java.class.path}"/>
28+ <pathelement path="lib/findbugs/lib/"/>
29+ </path>
30+
31+ <path id="checkstyle.lib.search.path">
32+ <pathelement path="${checkstyle.home}/"/>
33+ <pathelement path="${java.class.path}"/>
34+ <pathelement path="lib/checkstyle/lib/"/>
35+ </path>
36+
37+ <target name="-check_pmd" description="Check that pmd jar files are present">
38+ <available file="pmd.jar" type="file" property="pmd.jar.present">
39+ <filepath refid="pmd.lib.search.path"/>
40+ </available>
41+ <fail unless="pmd.jar.present" message="Please install pmd.jar in lib-directory (or in ant classpath) to run PMD."/>
42+ </target>
43+
44+ <target name="pmd" depends="compile, -check_pmd" description="Check the code with PMD">
45+ <path id="pmd.lib" >
46+ <pathelement location="${pmd.home}/lib/pmd.jar"/>
47+ <pathelement location="${pmd.home}/lib/jaxen.jar"/>
48+ </path>
49+ <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.lib"/>
50+ <mkdir dir="build/pmd"/>
51+ <pmd targetjdk="1.6" failuresPropertyName="pmd.num.warnings" rulesetfiles="tools/pmd/ruleset.xml">
52+ <formatter type="html" toFile="build/pmd/report.html"/>
53+ <formatter type="xml" toFile="build/pmd/report.xml"/>
54+ <fileset dir="src" includes="**/*.java"/>
55+ </pmd>
56+ <echo message="PMD finished, found ${pmd.num.warnings} warnings, see pmd/pmd_report.html"/>
57+ </target>
58+
59+ <target name="-check_findbugs" description="Check that findbugs jar files are present">
60+ <available file="findbugs.jar" type="file" property="findbugs.jar.present">
61+ <filepath refid="findbugs.lib.search.path"/>
62+ </available>
63+ <fail unless="findbugs.jar.present" message="Could not find findbugs.jar"/>
64+
65+ <available file="findbugs-ant.jar" type="file" property="findbugs-ant.jar.present">
66+ <filepath refid="findbugs.lib.search.path"/>
67+ </available>
68+ <fail unless="findbugs-ant.jar.present" message="Could not find findbugs-ant.jar"/>
69+ </target>
70+
71+ <target name="findbugs" depends="dist, -check_findbugs" description="Check the code with Findbugs">
72+ <path id="findbugs.lib" >
73+ <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
74+ <pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/>
75+ </path>
76+ <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.lib"/>
77+ <mkdir dir="build/findbugs"/>
78+ <findbugs projectname="Gearman-Java" home="${findbugs.home}" output="xml" outputFile="build/findbugs/findbugs.xml">
79+ <sourcePath path="src" />
80+ <class location="${dist.jar}" />
81+ </findbugs>
82+ </target>
83+
84+ <target name="-check_checkstyle" description="Check that checkstyle jar files are present">
85+ <available file="checkstyle-all.jar" type="file" property="checkstyle.jar.present">
86+ <filepath refid="checkstyle.lib.search.path"/>
87+ </available>
88+ <fail unless="checkstyle.jar.present" message="Please install checkstyle-all.jar in lib-directory (or in ant classpath) to run Checkstyle, see README."/>
89+ </target>
90+
91+ <target name="checkstyle" depends="compile, -check_checkstyle" description="Check the style with Checkstyle">
92+ <taskdef resource="checkstyletask.properties" classpath="${checkstyle.home}/checkstyle-all.jar"/>
93+ <mkdir dir="build/checkstyle"/>
94+ <checkstyle config="tools/checkstyle/ruleset.xml" failOnViolation="false">
95+ <fileset dir="src" includes="**/*.java"/>
96+ <formatter type="xml" toFile="build/checkstyle/errors.xml"/>
97+ </checkstyle>
98+ </target>
99+
100 <target name="usage">
101 <echo message="Build the ${ant.project.name} project."/>
102 <echo message=""/>
103
104=== added directory 'tools'
105=== added directory 'tools/checkstyle'
106=== added file 'tools/checkstyle/ruleset.xml'
107--- tools/checkstyle/ruleset.xml 1970-01-01 00:00:00 +0000
108+++ tools/checkstyle/ruleset.xml 2009-08-05 19:26:15 +0000
109@@ -0,0 +1,27 @@
110+<?xml version="1.0"?>
111+<!DOCTYPE module PUBLIC
112+ "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
113+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
114+<module name="Checker">
115+ <module name="NewlineAtEndOfFile"/>
116+ <module name="TreeWalker">
117+ <module name="AvoidStarImport"/>
118+ <module name="RedundantImport"/>
119+ <module name="UnusedImports"/>
120+ <module name="ImportOrder"/>
121+ <module name="FileLength"/>
122+ <module name="MethodLength">
123+ <property name="max" value="200"/>
124+ </module>
125+ <module name="AnonInnerLength">
126+ <property name="max" value="60"/>
127+ </module>
128+ <module name="ParameterNumber"/>
129+ <module name="NeedBraces"/>
130+ <module name="GenericWhitespace"/>
131+ <module name="MethodParamPad"/>
132+ <module name="NoWhitespaceAfter"/>
133+ <module name="FileContentsHolder"/>
134+ </module>
135+</module>
136+
137
138=== added directory 'tools/pmd'
139=== added file 'tools/pmd/ruleset.xml'
140--- tools/pmd/ruleset.xml 1970-01-01 00:00:00 +0000
141+++ tools/pmd/ruleset.xml 2009-08-05 18:34:44 +0000
142@@ -0,0 +1,31 @@
143+<?xml version="1.0" encoding="UTF-8"?>
144+<ruleset name="Custom ruleset for Gearman Java driver"
145+ xmlns="http://pmd.sf.net/ruleset/1.0.0"
146+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
147+ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
148+ xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
149+
150+ <description>PMD settings for lp:gearman-java</description>
151+
152+ <rule ref="rulesets/strings.xml"/>
153+ <rule ref="rulesets/basic.xml"/>
154+ <rule ref="rulesets/braces.xml"/>
155+ <rule ref="rulesets/clone.xml"/>
156+ <rule ref="rulesets/design.xml"/>
157+ <rule ref="rulesets/finalizers.xml"/>
158+ <rule ref="rulesets/imports.xml"/>
159+ <rule ref="rulesets/junit.xml"/>
160+ <rule ref="rulesets/logging-java.xml"/>
161+ <rule ref="rulesets/migrating.xml"/>
162+ <rule ref="rulesets/optimizations.xml">
163+ <!-- The following rules generate a lot of warnings... -->
164+ <exclude name="LocalVariableCouldBeFinal"/>
165+ <exclude name="MethodArgumentCouldBeFinal"/>
166+ </rule>
167+ <rule ref="rulesets/strictexception.xml"/>
168+ <rule ref="rulesets/strings.xml"/>
169+ <rule ref="rulesets/sunsecure.xml"/>
170+ <rule ref="rulesets/typeresolution.xml"/>
171+ <rule ref="rulesets/unusedcode.xml"/>
172+
173+</ruleset>

Subscribers

People subscribed via source and target branches