Merge pull request #7 from xenoamess-fork/add_checkstyle
add checkstyle.
diff --git a/.gitignore b/.gitignore
index e9ca771..8dec982 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
target/
.project
.settings
-.classpath
\ No newline at end of file
+.classpath
+.idea
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
new file mode 100644
index 0000000..e62645c
--- /dev/null
+++ b/checkstyle-suppressions.xml
@@ -0,0 +1,27 @@
+<?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 suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN" "https://checkstyle.org/dtds/suppressions_1_0.dtd">
+<suppressions>
+ <suppress checks="JavadocMethod" files=".*[/\\]test[/\\].*"/>
+ <suppress checks="JavadocPackage" files=".*[/\\]test[/\\].*"/>
+ <!-- exclude generated JMH classes from all checks -->
+ <suppress checks="[a-zA-Z0-9]*" files=".*[/\\]generated-test-sources[/\\].*"/>
+ <suppress checks="RedundantModifier" files="ConstructorUtilsTest" lines="0-99999"/>
+ <!-- Windows-only workaround -->
+ <suppress checks="NewlineAtEndOfFile" files="target[/\\]maven-archiver[/\\]pom.properties"/>
+</suppressions>
diff --git a/checkstyle.properties b/checkstyle.properties
new file mode 100644
index 0000000..ab415ba
--- /dev/null
+++ b/checkstyle.properties
@@ -0,0 +1,24 @@
+# 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.
+
+checkstyle.maxlinelen = 160
+checkstyle.lcurly.type = nl
+checkstyle.lcurly.method = nl
+checkstyle.lcurly.other = nl
+checkstyle.rcurly = alone
+checkstyle.paren.pad = ignore
+checkstyle.ignore.whitespace.cast = true
+checkstyle.javadoc.scope = package
+checkstyle.require.packagehtml = true
diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 0000000..aedcb2e
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,60 @@
+<?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
+ "-//Checkstyle//DTD Checkstyle Configuration 1.2//EN"
+ "https://checkstyle.org/dtds/configuration_1_2.dtd">
+
+<!-- Apache Commons Lang customization of default Checkstyle behavior -->
+<module name="Checker">
+ <property name="localeLanguage" value="en"/>
+ <module name="JavadocPackage"/>
+ <module name="NewlineAtEndOfFile">
+ <property name="lineSeparator" value="lf" />
+ </module>
+ <module name="FileTabCharacter">
+ <property name="fileExtensions" value="java,xml"/>
+ </module>
+ <module name="RegexpSingleline">
+ <!-- \s matches whitespace character, $ matches end of line. -->
+ <property name="format" value="\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+ <module name="SuppressionFilter">
+ <property name="file" value="checkstyle-suppressions.xml"/>
+ </module>
+ <module name="TreeWalker">
+ <module name="AvoidStarImport"/>
+ <module name="IllegalImport"/>
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+ <module name="NeedBraces"/>
+ <module name="JavadocMethod">
+ <property name="accessModifiers" value="public" />
+ </module>
+ <module name="ModifierOrder"/>
+ <module name="RedundantModifier"/>
+ <module name="UpperEll" />
+ <module name="LeftCurly"/>
+ <module name="NeedBraces"/>
+ <module name="RightCurly"/>
+ <module name="GenericWhitespace"/>
+ <module name="WhitespaceAfter"/>
+ <module name="NoWhitespaceBefore"/>
+ </module>
+</module>
diff --git a/core/pom.xml b/core/pom.xml
index 6028091..10a2284 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,6 +21,10 @@
<version>1.1.3-SNAPSHOT</version>
<packaging>bundle</packaging>
+ <properties>
+ <checkstyle.configdir>${basedir}/..</checkstyle.configdir>
+ </properties>
+
<build>
<resources>
<resource>
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 9a617c7..7109e1d 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -23,6 +23,10 @@
<packaging>pom</packaging>
<name>Apache FtpServer</name>
+ <properties>
+ <checkstyle.configdir>${basedir}/..</checkstyle.configdir>
+ </properties>
+
<build>
<finalName>apache-ftpserver-${project.version}</finalName>
<plugins>
diff --git a/examples/ftpserver-example-spring-war/pom.xml b/examples/ftpserver-example-spring-war/pom.xml
index 3424f16..9f638a1 100644
--- a/examples/ftpserver-example-spring-war/pom.xml
+++ b/examples/ftpserver-example-spring-war/pom.xml
@@ -24,6 +24,10 @@
<packaging>war</packaging>
<version>1.1.3-SNAPSHOT</version>
+ <properties>
+ <checkstyle.configdir>${basedir}/../..</checkstyle.configdir>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/examples/ftpserver-osgi-ftplet-service/pom.xml b/examples/ftpserver-osgi-ftplet-service/pom.xml
index b9821ab..516ed69 100644
--- a/examples/ftpserver-osgi-ftplet-service/pom.xml
+++ b/examples/ftpserver-osgi-ftplet-service/pom.xml
@@ -28,7 +28,11 @@
<name>FtpServer OSGi Ftplet service example</name>
<packaging>bundle</packaging>
<version>1.1.3-SNAPSHOT</version>
-
+
+ <properties>
+ <checkstyle.configdir>${basedir}/../..</checkstyle.configdir>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.ftpserver</groupId>
diff --git a/examples/ftpserver-osgi-spring-service/pom.xml b/examples/ftpserver-osgi-spring-service/pom.xml
index 97dbd15..090bdd4 100644
--- a/examples/ftpserver-osgi-spring-service/pom.xml
+++ b/examples/ftpserver-osgi-spring-service/pom.xml
@@ -28,7 +28,11 @@
<name>FtpServer OSGi Spring-DM example</name>
<packaging>bundle</packaging>
<version>1.1.3-SNAPSHOT</version>
-
+
+ <properties>
+ <checkstyle.configdir>${basedir}/../..</checkstyle.configdir>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.ftpserver</groupId>
diff --git a/examples/pom.xml b/examples/pom.xml
index 373c074..71124b7 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -34,4 +34,9 @@
<module>ftpserver-osgi-ftplet-service</module>
<module>ftpserver-osgi-spring-service</module>
</modules>
+
+ <properties>
+ <checkstyle.configdir>${basedir}/..</checkstyle.configdir>
+ </properties>
+
</project>
diff --git a/ftplet-api/pom.xml b/ftplet-api/pom.xml
index 8cb2d50..9fa8a6f 100644
--- a/ftplet-api/pom.xml
+++ b/ftplet-api/pom.xml
@@ -72,5 +72,6 @@
<properties>
<maven.compile.source>1.8</maven.compile.source>
<maven.compile.target>1.8</maven.compile.target>
+ <checkstyle.configdir>${basedir}/..</checkstyle.configdir>
</properties>
</project>
diff --git a/pom.xml b/pom.xml
index 743b379..e7bd401 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,6 +173,9 @@
<slf4j.api.version>1.7.32</slf4j.api.version>
<slf4j.log4j12.version>1.7.32</slf4j.log4j12.version>
<spring.context.version>2.5.5</spring.context.version>
+ <checkstyle.plugin.version>3.1.2</checkstyle.plugin.version>
+ <checkstyle.version>8.45.1</checkstyle.version>
+ <checkstyle.configdir>${basedir}</checkstyle.configdir>
</properties>
<dependencyManagement>
@@ -501,6 +504,42 @@
<module>examples</module>
</modules>
</profile>
+ <profile>
+ <id>enforce</id>
+ <activation>
+ <property>
+ <name>enforce.activate</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.plugin.version}</version>
+ <configuration>
+ <configLocation>${checkstyle.configdir}/checkstyle.xml</configLocation>
+ <suppressionsLocation>${checkstyle.configdir}/checkstyle-suppressions.xml</suppressionsLocation>
+ <enableRulesSummary>false</enableRulesSummary>
+ <propertyExpansion>basedir=${basedir}</propertyExpansion>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>com.puppycrawl.tools</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>9.2</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<modules>