Add import-control checks to Checkstyle (these found the recent dependency issues)
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 11 Dec 2010 20:38:42 +0000 (20:38 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 11 Dec 2010 20:38:42 +0000 (20:38 +0000)
Move checkstyle config to res/checkstyle to stop it cluttering up the root

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1044710 13f79535-47bb-0310-9956-ffa450edef68

build.xml
checkstyle.xml [deleted file]
res/checkstyle/checkstyle.xml [new file with mode: 0644]
res/checkstyle/javax-checkstyle.xml [new file with mode: 0644]
res/checkstyle/javax-import-control.xml [new file with mode: 0644]
res/checkstyle/org-checkstyle.xml [new file with mode: 0644]
res/checkstyle/org-import-control.xml [new file with mode: 0644]

index 06a22aa..6c1a85c 100644 (file)
--- a/build.xml
+++ b/build.xml
   <target name="validate" depends="download-validate" if="${execute.validate}">
     <taskdef resource="checkstyletask.properties"
              classpath="${checkstyle.jar}" />
-    <checkstyle config="checkstyle.xml">
+    <checkstyle config="res/checkstyle/checkstyle.xml">
       <fileset dir="." >
         <patternset refid="text.files" />
         <exclude name=".*/**"/>
         <exclude name="**/tomcat-deps/**"/>
       </fileset>
     </checkstyle>
+    <!-- javax package checks -->
+    <checkstyle config="res/checkstyle/javax-checkstyle.xml">
+      <fileset dir="java/javax" >
+        <include name="**/*.java"/>
+      </fileset>
+    </checkstyle>
+    <!-- org package checks -->
+    <checkstyle config="res/checkstyle/org-checkstyle.xml">
+      <fileset dir="java/org" >
+        <include name="**/*.java"/>
+      </fileset>
+    </checkstyle>
   </target>
 
   <target name="compile" depends="build-prepare,download-compile,validate">
diff --git a/checkstyle.xml b/checkstyle.xml
deleted file mode 100644 (file)
index 024bf91..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<!DOCTYPE module PUBLIC
-    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
-    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
-<module name="Checker">
-  <!-- When adding checks, keep to the order checks are listed under         -->
-  <!-- 'Standard Checks' in the Checkstyle documentation:                    -->
-  <!-- http://checkstyle.sourceforge.net/config_coding.html                  -->
-
-  <!-- Whitespace -->
-  <module name="FileTabCharacter"/>
-
-  <module name="TreeWalker">
-    <!-- Block Checks -->
-    <!--  ~60 errors
-    <module name="AvoidNestedBlocks"/>
-    -->
-
-    <!-- Coding -->
-    <module name="IllegalInstantiation"/>
-    
-    <!-- Imports -->
-    <module name="AvoidStarImport"/>
-    <module name="AvoidStaticImport"/>
-    <module name="IllegalImport"/>
-    <module name="ImportOrder">
-        <property name="groups" value="java,javax,async,jsp2,junit,org,util"/>
-        <property name="ordered" value="true"/>
-        <property name="separated" value="true"/>
-        <property name="option" value="above"/>
-    </module>
-    <module name="RedundantImport"/>
-    <module name="UnusedImports"/>
-    
-    <!--  Modifiers -->
-    <module name="ModifierOrder"/>
-    <!-- ~1750 errors
-    <module name="RedundantModifier"/>
-    -->
-    
-    <!-- Whitespace -->
-    <!-- Can't handle HashMap<String,Class<?>[]>
-    https://sourceforge.net/tracker/?func=detail&aid=3039718&group_id=29721&atid=397078
-    <module name="GenericWhitespace"/>
-    -->
-    <module name="EmptyForInitializerPad"/>
-    <module name="EmptyForIteratorPad"/>
-    <!--  ~ 1000 errors
-    <module name="OperatorWrap">
-      <property name="option" value="oel"/>
-    </module>
-    -->
-  </module>
-</module>
\ No newline at end of file
diff --git a/res/checkstyle/checkstyle.xml b/res/checkstyle/checkstyle.xml
new file mode 100644 (file)
index 0000000..024bf91
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+<module name="Checker">
+  <!-- When adding checks, keep to the order checks are listed under         -->
+  <!-- 'Standard Checks' in the Checkstyle documentation:                    -->
+  <!-- http://checkstyle.sourceforge.net/config_coding.html                  -->
+
+  <!-- Whitespace -->
+  <module name="FileTabCharacter"/>
+
+  <module name="TreeWalker">
+    <!-- Block Checks -->
+    <!--  ~60 errors
+    <module name="AvoidNestedBlocks"/>
+    -->
+
+    <!-- Coding -->
+    <module name="IllegalInstantiation"/>
+    
+    <!-- Imports -->
+    <module name="AvoidStarImport"/>
+    <module name="AvoidStaticImport"/>
+    <module name="IllegalImport"/>
+    <module name="ImportOrder">
+        <property name="groups" value="java,javax,async,jsp2,junit,org,util"/>
+        <property name="ordered" value="true"/>
+        <property name="separated" value="true"/>
+        <property name="option" value="above"/>
+    </module>
+    <module name="RedundantImport"/>
+    <module name="UnusedImports"/>
+    
+    <!--  Modifiers -->
+    <module name="ModifierOrder"/>
+    <!-- ~1750 errors
+    <module name="RedundantModifier"/>
+    -->
+    
+    <!-- Whitespace -->
+    <!-- Can't handle HashMap<String,Class<?>[]>
+    https://sourceforge.net/tracker/?func=detail&aid=3039718&group_id=29721&atid=397078
+    <module name="GenericWhitespace"/>
+    -->
+    <module name="EmptyForInitializerPad"/>
+    <module name="EmptyForIteratorPad"/>
+    <!--  ~ 1000 errors
+    <module name="OperatorWrap">
+      <property name="option" value="oel"/>
+    </module>
+    -->
+  </module>
+</module>
\ No newline at end of file
diff --git a/res/checkstyle/javax-checkstyle.xml b/res/checkstyle/javax-checkstyle.xml
new file mode 100644 (file)
index 0000000..23d5101
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+<module name="Checker">
+  <!-- When adding checks, keep to the order checks are listed under         -->
+  <!-- 'Standard Checks' in the Checkstyle documentation:                    -->
+  <!-- http://checkstyle.sourceforge.net/config_coding.html                  -->
+
+  <!-- Specific checks for javax.* packages -->
+
+  <module name="TreeWalker">
+    <module name="ImportControl">
+      <property name="file" value="res/checkstyle/javax-import-control.xml"/>
+    </module>
+  </module>
+</module>
\ No newline at end of file
diff --git a/res/checkstyle/javax-import-control.xml b/res/checkstyle/javax-import-control.xml
new file mode 100644 (file)
index 0000000..2150ae2
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<!DOCTYPE import-control PUBLIC
+    "-//Puppy Crawl//DTD Import Control 1.1//EN"
+    "http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
+
+<import-control pkg="javax">
+  <allow pkg="java"/>
+  <subpackage name="annotation">
+    <allow pkg="javax.annotation"/>
+  </subpackage>
+  <subpackage name="ejb">
+    <allow pkg="javax.ejb"/>
+  </subpackage>
+  <subpackage name="el">
+    <allow pkg="javax.el"/>
+  </subpackage>
+  <subpackage name="mail">
+    <allow pkg="javax.mail"/>
+  </subpackage>
+  <subpackage name="persistence">
+    <allow pkg="javax.persistence"/>
+  </subpackage>
+  <subpackage name="servlet">
+    <allow pkg="javax.servlet"/>
+    <disallow pkg="javax.servlet.jsp" local-only="true"/>
+    <subpackage name="jsp">
+      <allow pkg="javax.el"/>
+      <allow pkg="javax.servlet.jsp"/>
+    </subpackage>
+  </subpackage>
+  <subpackage name="xml.ws">
+    <allow pkg="javax.xwl.ws"/>
+  </subpackage>
+</import-control>
\ No newline at end of file
diff --git a/res/checkstyle/org-checkstyle.xml b/res/checkstyle/org-checkstyle.xml
new file mode 100644 (file)
index 0000000..12da665
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+<module name="Checker">
+  <!-- When adding checks, keep to the order checks are listed under         -->
+  <!-- 'Standard Checks' in the Checkstyle documentation:                    -->
+  <!-- http://checkstyle.sourceforge.net/config_coding.html                  -->
+
+  <!-- Specific checks for javax.* packages -->
+
+  <module name="TreeWalker">
+    <module name="ImportControl">
+      <property name="file" value="res/checkstyle/org-import-control.xml"/>
+    </module>
+  </module>
+</module>
\ No newline at end of file
diff --git a/res/checkstyle/org-import-control.xml b/res/checkstyle/org-import-control.xml
new file mode 100644 (file)
index 0000000..ea23ff9
--- /dev/null
@@ -0,0 +1,102 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<!DOCTYPE import-control PUBLIC
+    "-//Puppy Crawl//DTD Import Control 1.1//EN"
+    "http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
+
+<import-control pkg="org.apache">
+  <!-- Anything in J2SE is OK but need to list javax by package as not
+       all javax packages are in J2SE -->
+  <allow pkg="java"/>
+  <allow class="javax.imageio.ImageIO"/>
+  <allow pkg="javax.management"/>
+  <allow pkg="javax.naming"/>
+  <allow pkg="javax.net"/>
+  <allow pkg="javax.rmi"/>
+  <allow pkg="javax.security"/>
+  <allow pkg="javax.sql"/>
+  <allow pkg="javax.xml"/>
+  <allow pkg="org.w3c.dom"/>
+  <allow pkg="org.xml.sax"/>
+  <subpackage name="catalina">
+    <allow pkg="javax.annotation"/>
+    <allow pkg="javax.ejb"/>
+    <allow pkg="javax.persistence"/>
+    <allow pkg="javax.servlet"/>
+    <allow pkg="org.apache.catalina"/>
+    <allow pkg="org.apache.coyote"/>
+    <allow pkg="org.apache.juli"/>
+    <allow pkg="org.apache.naming"/>
+    <allow pkg="org.apache.tomcat"/>
+    <allow pkg="org.apache.tools.ant"/>
+  </subpackage>
+  <subpackage name="coyote">
+    <allow pkg="org.apache.coyote"/>
+    <allow pkg="org.apache.juli"/>
+    <allow pkg="org.apache.tomcat.jni"/>
+    <allow pkg="org.apache.tomcat.util"/>
+  </subpackage>
+  <subpackage name="el">
+    <allow pkg="javax.el"/>
+    <allow pkg="org.apache.el"/>
+  </subpackage>
+  <subpackage name="jasper">
+    <allow pkg="javax.el"/>
+    <allow pkg="javax.servlet"/>
+    <allow pkg="org.apache.jasper"/>
+    <allow pkg="org.apache.juli"/>
+    <allow pkg="org.apache.tomcat" exact-match="true"/>
+    <allow pkg="org.apache.tomcat.util.scan"/>
+    <allow pkg="org.apache.tools.ant"/>
+    <allow pkg="org.eclipse.jdt"/>
+  </subpackage>
+  <subpackage name="juli">
+    <allow pkg="org.apache.juli"/>
+  </subpackage>
+  <subpackage name="naming">
+    <allow pkg="javax.mail"/>
+    <allow pkg="javax.wsdl"/>
+    <allow pkg="org.apache.naming"/>
+    <!-- To remove? -->
+    <allow class="org.apache.catalina.util.RequestUtil"/>
+    <allow class="org.apache.tomcat.util.http.FastHttpDateFormat"/>
+  </subpackage>
+  <subpackage name="tomcat">
+    <allow pkg="javax.servlet"/>
+    <subpackage name="buildutil">
+      <allow pkg="org.apache.tools.ant"/>
+    </subpackage>
+    <subpackage name="jni">
+      <!-- To remove? -->
+      <allow class="org.apache.tomcat.util.ExceptionUtils"/>
+    </subpackage>
+    <subpackage name="util">
+      <allow pkg="org.apache.juli"/>
+      <allow pkg="org.apache.tomcat.jni"/>
+      <allow pkg="org.apache.tomcat.util"/>
+      <disallow pkg="org.apache.util.scan"/>
+      <!-- To remove? -->
+      <allow class="org.apache.catalina.Globals"/>
+      <allow class="org.apache.coyote.RequestGroupInfo"/>
+      <!-- end to remove -->
+      <subpackage name="scan">
+        <allow pkg="org.apache.tomcat" exact-match="true"/>
+      </subpackage>
+    </subpackage>
+  </subpackage>
+</import-control>
\ No newline at end of file