Browse Source

ZOOKEEPER-412: checkstyle target fails trunk build (Akihiro Suda via cnauroth)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1720227 13f79535-47bb-0310-9956-ffa450edef68
Chris Nauroth 9 years ago
parent
commit
750bd2a92e
4 changed files with 41 additions and 33 deletions
  1. 2 0
      CHANGES.txt
  2. 15 26
      build.xml
  3. 1 1
      ivy.xml
  4. 23 6
      src/java/test/checkstyle.xml

+ 2 - 0
CHANGES.txt

@@ -247,6 +247,8 @@ BUGFIXES:
   ZOOKEEPER-1029: C client bug in zookeeper_init (if bad hostname is given)
   (fpj via cnauroth)
 
+  ZOOKEEPER-412: checkstyle target fails trunk build (Akihiro Suda via cnauroth)
+
 IMPROVEMENTS:
   ZOOKEEPER-1660 Documentation for Dynamic Reconfiguration (Reed Wanderman-Milne via shralex)  
 

+ 15 - 26
build.xml

@@ -20,7 +20,8 @@
 <project name="ZooKeeper" default="jar" 
 xmlns:ivy="antlib:org.apache.ivy.ant"
 xmlns:artifact="antlib:org.apache.maven.artifact.ant"
-xmlns:maven="antlib:org.apache.maven.artifact.ant">
+xmlns:maven="antlib:org.apache.maven.artifact.ant"
+xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant">
 
     <!-- read build.properties from the basedir if any -->
     <property file="${basedir}/build.properties" />
@@ -1698,32 +1699,20 @@ xmlns:maven="antlib:org.apache.maven.artifact.ant">
         </cobertura-report>
     </target>
 
-    <target name="checkstyle" depends="checkstyle.check, set-checkstyle-classpath" if="checkstyle.home" 
-			description="Run optional third-party tool targets">
-    	<taskdef resource="checkstyletask.properties">
-        	<classpath refid="checkstyle-classpath"/>
-        </taskdef>
-        <mkdir dir="${test.java.build.dir}"/>
-        <checkstyle config="${test.src.dir}/checkstyle.xml" failOnViolation="false">
-        	<fileset dir="${src.dir}/java" includes="**/*.java" excludes="**/generated/**"/>
-        	<formatter type="xml" toFile="${test.java.build.dir}/checkstyle-errors.xml"/>
-        </checkstyle>
-        <xslt style="${test.src.dir}/checkstyle-noframes-sorted.xsl" in="${test.java.build.dir}/checkstyle-errors.xml"
-        	out="${test.java.build.dir}/checkstyle-errors.html"/>
-    </target>
-
-    <target name="checkstyle.check" unless="checkstyle.home">
-    	<fail message="'checkstyle.home' is not defined. Please pass -Dcheckstyle.home=&lt;base of checkstyle installation&gt; 
-		to Ant on the command-line." />
+    <target name="checkstyle" depends="ivy-retrieve-test" description="Run Checkstyle coding standard checks">
+      <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" uri="antlib:com.puppycrawl.tools.checkstyle.ant">
+        <classpath>
+          <fileset dir="${ivy.test.lib}" includes="*.jar" />
+        </classpath>
+      </taskdef>
+      <mkdir dir="${test.java.build.dir}"/>
+      <cs:checkstyle config="${test.src.dir}/checkstyle.xml" failOnViolation="false">
+        <fileset dir="${src.dir}/java" includes="**/*.java" excludes="**/generated/**"/>
+        <formatter type="xml" toFile="${test.java.build.dir}/checkstyle-errors.xml"/>
+      </cs:checkstyle>
+      <xslt style="${test.src.dir}/checkstyle-noframes-sorted.xsl" in="${test.java.build.dir}/checkstyle-errors.xml"
+            out="${test.java.build.dir}/checkstyle-errors.html"/>
     </target>
-    
-    <target name="set-checkstyle-classpath">
-    	<path id="checkstyle-classpath">
-        	<fileset dir="${checkstyle.home}">
-			<include name="**/*.jar"/>
-         	</fileset>
- 	</path>
-    </target>	
 
     <!-- ================================================================== -->
     <!-- Perform audit activities for the release                           -->

+ 1 - 1
ivy.xml

@@ -60,7 +60,7 @@
     <dependency org="junit" name="junit" rev="4.12" conf="test->default"/>
 	<dependency org="org.mockito" name="mockito-all" rev="1.8.2"
                conf="test->default"/>
-    <dependency org="checkstyle" name="checkstyle" rev="5.0"
+    <dependency org="com.puppycrawl.tools" name="checkstyle" rev="6.13"
                 conf="test->default"/>
 
     <dependency org="jdiff" name="jdiff" rev="1.0.9"

+ 23 - 6
src/java/test/checkstyle.xml

@@ -4,6 +4,23 @@
     "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
 
 <!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!--
+  [Forked from Hadoop@2d7363b27360e36fdd62546c0f9d0b1d78133f29]
 
   Checkstyle configuration for Zookeeper that is based on the sun_checks.xml file
   that is bundled with Checkstyle and includes checks for:
@@ -35,7 +52,7 @@
 
     <!-- Checks that a package.html file exists for each package.     -->
     <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
-    <module name="PackageHtml"/>
+    <module name="JavadocPackage"/>
 
     <!-- Checks whether files end with a new line.                        -->
     <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
@@ -45,6 +62,8 @@
     <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
     <module name="Translation"/>
 
+    <module name="FileLength"/>
+    <module name="FileTabCharacter"/>
 
     <module name="TreeWalker">
 
@@ -96,8 +115,9 @@
 
         <!-- Checks for Size Violations.                    -->
         <!-- See http://checkstyle.sf.net/config_sizes.html -->
-        <module name="FileLength"/>
-        <module name="LineLength"/>
+        <module name="LineLength">
+          <property name="ignorePattern" value="^import"/>
+        </module>
         <module name="MethodLength"/>
         <module name="ParameterNumber"/>
 
@@ -110,7 +130,6 @@
         <module name="NoWhitespaceBefore"/>
         <module name="ParenPad"/>
         <module name="TypecastParenPad"/>
-        <module name="TabCharacter"/>
         <module name="WhitespaceAfter">
 	    	<property name="tokens" value="COMMA, SEMI"/>
 		</module>
@@ -134,7 +153,6 @@
         <!-- Checks for common coding problems               -->
         <!-- See http://checkstyle.sf.net/config_coding.html -->
         <!-- module name="AvoidInlineConditionals"/-->
-        <module name="DoubleCheckedLocking"/>
         <module name="EmptyStatement"/>
         <module name="EqualsHashCode"/>
         <module name="HiddenField">
@@ -143,7 +161,6 @@
         <module name="IllegalInstantiation"/>
         <module name="InnerAssignment"/>
         <module name="MissingSwitchDefault"/>
-        <module name="RedundantThrows"/>
         <module name="SimplifyBooleanExpression"/>
         <module name="SimplifyBooleanReturn"/>