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

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


The following commit(s) were added to refs/heads/master by this push:
     new ab4450645 [java] introduce skipCodeStyleChecks gradle property
ab4450645 is described below

commit ab445064588906111e46836d84733999c0cd2006
Author: Alexey Serbin <ale...@apache.org>
AuthorDate: Fri Jun 23 17:22:17 2023 -0700

    [java] introduce skipCodeStyleChecks gradle property
    
    It doesn't make much sense to run code style verification in various
    non-development build environments since the code isn't supposed
    to change and be pushed back into the repository in such a case.  All
    those verification and checks are enabled by default to be run in
    standard development environment and various pre-commit verification
    builds.
    
    With this patch, it's now possible to define the 'skipCodeStyleChecks'
    property to avoid running those code style verifications for Java and
    Scala code:
    
      ./gradlew -PskipCodeStyleChecks=true ...
    
    Change-Id: I6e67e71ab21908166aba0f83a10b4aba0fdc5f3d
    Reviewed-on: http://gerrit.cloudera.org:8080/20116
    Tested-by: Kudu Jenkins
    Reviewed-by: Abhishek Chennaka <achenn...@cloudera.com>
---
 java/gradle/quality.gradle | 59 +++++++++++++++++++++++++++-------------------
 1 file changed, 35 insertions(+), 24 deletions(-)

diff --git a/java/gradle/quality.gradle b/java/gradle/quality.gradle
index 02a896603..de58c8283 100644
--- a/java/gradle/quality.gradle
+++ b/java/gradle/quality.gradle
@@ -17,29 +17,51 @@
 
 // This file contains common tasks and configuration for checking the quality 
of the code.
 
-apply plugin: "checkstyle" // Ensures Java code follows the defined coding 
style.
 apply plugin: "com.github.spotbugs"   // Performs static code analysis to look 
for bugs in Java code.
 apply plugin: "com.github.ben-manes.versions" // Provides a task to determine 
which dependencies have updates.
 apply plugin: "ru.vyarus.animalsniffer" // Ensures Java code uses APIs from a 
particular version of Java.
-apply plugin: "scalafmt" // Automatically formats Scala code on each build.
 
 def ignoreCheckFailures = false
 if (propertyExists("ignoreCheckFailures")) {
   ignoreCheckFailures = true
 }
 
-checkstyle {
-  toolVersion = versions.checkstyle
-  configDir = file("$rootProject.projectDir/config/checkstyle")
-  ignoreFailures = ignoreCheckFailures
-  maxWarnings = 0
-  showViolations = true
-}
+// For other than development environments (e.g., building Kudu release JARs
+// in an automated release engineering environment), it makes sense to skip
+// code style verification tasks since the code is assumed to be already
+// passed those in various pre-commit builds.  For that, define the
+// 'skipCodeStyleChecks' property.
+if (!propertyExists("skipCodeStyleChecks")) {
+  // Ensures Java code follows the defined coding style.
+  apply plugin: "checkstyle"
+
+  // Automatically formats Scala code on each build.
+  apply plugin: "scalafmt"
+
+  checkstyle {
+    toolVersion = versions.checkstyle
+    configDir = file("$rootProject.projectDir/config/checkstyle")
+    ignoreFailures = ignoreCheckFailures
+    maxWarnings = 0
+    showViolations = true
+  }
+
+  // Create an aggregate checkstyle task.
+  // This simplifies running checkstyle on all the code by only needing one 
task instead of multiple in your command.
+  task checkstyle(dependsOn: [checkstyleMain, checkstyleTest], group: 
"Verification") {
+    description = "Run Checkstyle analysis."
+  }
+
+  scalafmt {
+    configFilePath = "$rootDir/.scalafmt.conf"
+  }
 
-// Create an aggregate checkstyle task.
-// This simplifies running checkstyle on all the code by only needing one task 
instead of multiple in your command.
-task checkstyle(dependsOn: [checkstyleMain, checkstyleTest], group: 
"Verification") {
-  description = "Run Checkstyle analysis."
+  // Run scalafmt on compile.
+  tasks.withType(ScalaCompile) {
+    if (!propertyExists("skipFormat")) {
+       dependsOn("scalafmtAll")
+    }
+  }
 }
 
 spotbugs {
@@ -63,17 +85,6 @@ task spotbugs(dependsOn: [spotbugsMain, spotbugsTest], 
group: "Verification") {
   description = "Run SpotBugs analysis."
 }
 
-scalafmt {
-  configFilePath = "$rootDir/.scalafmt.conf"
-}
-
-// Run scalafmt on compile.
-tasks.withType(ScalaCompile) {
-  if (!propertyExists("skipFormat")) {
-     dependsOn("scalafmtAll")
-  }
-}
-
 // Errorprone doesn't support Java 11+
 // https://github.com/google/error-prone/issues/1106
 if(!JavaVersion.current().isJava11Compatible()) {

Reply via email to