ACCUMULO-1641 Add checkstyle plugin for API check
diff --git a/bin/runex b/bin/runex
index feabbe9..aa55ef3 100755
--- a/bin/runex
+++ b/bin/runex
@@ -19,7 +19,7 @@
main_args="${*:2}"
if command -v accumulo > /dev/null 2>&1 ; then
- av_arg="-Daccumulo.version=`accumulo version`"
+ av_arg="-Daccumulo.version=`accumulo version | tail -n 1`"
fi
mvn -q exec:java -Dexec.mainClass="org.apache.accumulo.examples.$main_class" $av_arg -Dexec.args="$main_args"
diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100755
index 0000000..4bfef83
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,28 @@
+<?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.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+<module name="Checker">
+ <property name="charset" value="UTF-8"/>
+ <module name="TreeWalker">
+ <module name="RegexpSinglelineJava">
+ <!--check that only Accumulo public APIs are imported-->
+ <property name="format" value="import\s+org\.apache\.accumulo\.(.*\.(impl|thrift|crypto)\..*|(?!core|minicluster|examples).*|core\.(?!client|data|security|cli|iterators).*)"/>
+ <property name="ignoreComments" value="true" />
+ <property name="message" value="Accumulo non-public classes imported" />
+ </module>
+ </module>
+</module>
+
diff --git a/pom.xml b/pom.xml
index d994d0e..834c761 100644
--- a/pom.xml
+++ b/pom.xml
@@ -113,6 +113,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <!-- This was added to ensure project only uses public API. Run with the following:
+ mvn checkstyle:checkstyle
+ -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <configLocation>checkstyle.xml</configLocation>
+ </configuration>
+ </plugin>
</plugins>
</build>