You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by hs...@apache.org on 2021/04/08 23:42:32 UTC

[bookkeeper] branch master updated: ISSUE #2640: BP-43 Integrate checkstyle with gradle

This is an automated email from the ASF dual-hosted git repository.

hsaputra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new acbc20d  ISSUE #2640: BP-43 Integrate checkstyle with gradle
acbc20d is described below

commit acbc20dacf3d13c91a872c24e45d0c4d69bb9733
Author: Prashant Kumar <65...@users.noreply.github.com>
AuthorDate: Thu Apr 8 16:42:21 2021 -0700

    ISSUE #2640: BP-43 Integrate checkstyle with gradle
    
    ### Motivation
    
    **Migrate bookkeeper to gradle.**
    Checkstyle is gradle as well as maven plugin which checks for code formatting spacing etc.
    **How to run**
     `./gradlew checkstyleMain  `
    
    ### Changes
    Integrate gradle build with checkstyle plugin
    
    
    Master Issue: #2640
    
    
    
    Reviewers: Henry Saputra <hs...@apache.org>, Matteo Merli <mm...@apache.org>
    
    This closes #2680 from pkumar-singh/merge_internal_gradle_checkstyle, closes #2640
---
 build.gradle                                              | 14 +++++++++++++-
 buildtools/src/main/resources/bookkeeper/checkstyle.xml   |  2 +-
 buildtools/src/main/resources/bookkeeper/suppressions.xml |  7 +++++++
 gradle.properties                                         |  3 ++-
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/build.gradle b/build.gradle
index df1b3d0..1886606 100644
--- a/build.gradle
+++ b/build.gradle
@@ -25,6 +25,7 @@ buildscript {
 plugins {
     id 'com.google.protobuf'
     id 'java'
+    id 'checkstyle'
 }
 
 subprojects {
@@ -35,7 +36,6 @@ apply from: "$rootDir/version.gradle"
 
 allprojects {
     apply from: "$rootDir/dependencies.gradle"
-
     if (it.path != ':circe-checksum:src:main:circe'
         && it.path != ':cpu-affinity:src:main:affinity'
         && it.name != 'src'
@@ -43,6 +43,18 @@ allprojects {
         apply plugin: 'java'
         apply plugin: 'maven-publish'
         apply plugin: 'signing'
+        apply plugin: "checkstyle"
+        checkstyle {
+            toolVersion "${checkStyleVersion}"
+            configFile file("$rootDir/buildtools/src/main/resources/bookkeeper/checkstyle.xml")
+            checkstyleMain {
+                source ='src/main/java'
+            }
+
+            checkstyleTest {
+                source ='src/test/java'
+            }
+        }
 
         task testJar(type: Jar, dependsOn: testClasses) {
             classifier = 'tests'
diff --git a/buildtools/src/main/resources/bookkeeper/checkstyle.xml b/buildtools/src/main/resources/bookkeeper/checkstyle.xml
index 1c938d3..b79bfdd 100644
--- a/buildtools/src/main/resources/bookkeeper/checkstyle.xml
+++ b/buildtools/src/main/resources/bookkeeper/checkstyle.xml
@@ -60,7 +60,7 @@ page at http://checkstyle.sourceforge.net/config.html -->
         <property name="checkFormat" value="$1"/>
     </module>
     <module name="SuppressionFilter">
-        <property name="file" value="${checkstyle.suppressions.file}" default="suppressions.xml" />
+        <property name="file" value="${checkstyle.suppressions.file}" default="./buildtools/src/main/resources/bookkeeper/suppressions.xml" />
     </module>
 
     <!-- Check that every module has a package-info.java -->
diff --git a/buildtools/src/main/resources/bookkeeper/suppressions.xml b/buildtools/src/main/resources/bookkeeper/suppressions.xml
index 232f19b..a0be7b3 100644
--- a/buildtools/src/main/resources/bookkeeper/suppressions.xml
+++ b/buildtools/src/main/resources/bookkeeper/suppressions.xml
@@ -29,4 +29,11 @@
 
     <!-- suppress all checks in the copied code -->
     <suppress checks=".*" files=".+[\\/]com[\\/]scurrilous[\\/]circe[\\/].+\.java" />
+    <suppress checks="AvoidStarImport" files=".*[\\/]distributedlog[\\/].*"/>
+    <suppress checks="StaticVariableName" files=".*[\\/]distributedlog[\\/].*"/>
+    <suppress checks="LocalVariableName" files=".*[\\/]distributedlog[\\/].*"/>
+    <suppress checks="LocalFinalVariableName" files=".*[\\/]distributedlog[\\/].*"/>
+    <suppress checks="MemberName" files=".*[\\/]distributedlog[\\/].*"/>
+    <!-- suppress all checks in the generated directories -->
+    <suppress checks=".*" files=".*[\\/]thrift[\\/].*"/>
 </suppressions>
diff --git a/gradle.properties b/gradle.properties
index bde5141..85ee5c8 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -19,4 +19,5 @@
 #
 #
 
-protobufPluginVersion=0.8.15
\ No newline at end of file
+protobufPluginVersion=0.8.15
+checkStyleVersion=6.19
\ No newline at end of file