You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2020/07/25 20:04:51 UTC

[calcite] branch master updated: [CALCITE-4141] Make checkstyle tasks relocatable to support Gradle build cache

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0fdf185  [CALCITE-4141] Make checkstyle tasks relocatable to support Gradle build cache
0fdf185 is described below

commit 0fdf185340872a8c8e41073dbc1367d57cd3ffd0
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Sat Jul 25 21:46:53 2020 +0300

    [CALCITE-4141] Make checkstyle tasks relocatable to support Gradle build cache
---
 build.gradle.kts                       | 14 +++++++++-----
 src/main/config/checkstyle/checker.xml | 11 ++++++-----
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/build.gradle.kts b/build.gradle.kts
index 7512783..d5824b3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -309,15 +309,13 @@ allprojects {
     }
     if (!skipCheckstyle) {
         apply<CheckstylePlugin>()
+        // This will be config_loc in Checkstyle (checker.xml)
+        val configLoc = File(rootDir, "src/main/config/checkstyle")
         checkstyle {
             toolVersion = "checkstyle".v
             isShowViolations = true
-            configDirectory.set(File(rootDir, "src/main/config/checkstyle"))
+            configDirectory.set(configLoc)
             configFile = configDirectory.get().file("checker.xml").asFile
-            configProperties = mapOf(
-                "base_dir" to rootDir.toString(),
-                "cache_file" to buildDir.resolve("checkstyle/cacheFile")
-            )
         }
         tasks.register("checkstyleAll") {
             dependsOn(tasks.withType<Checkstyle>())
@@ -328,6 +326,12 @@ allprojects {
             // On the other hand, supporessions.xml still analyzes the file, and
             // then it recognizes it should suppress all the output.
             excludeJavaCcGenerated()
+            // Workaround for https://github.com/gradle/gradle/issues/13927
+            // Absolute paths must not be used as they defeat Gradle build cache
+            // Unfortunately, Gradle passes only config_loc variable by default, so we make
+            // all the paths relative to config_loc
+            configProperties!!["cache_file"] =
+                buildDir.resolve("checkstyle/cacheFile").relativeTo(configLoc)
         }
     }
     if (!skipAutostyle || !skipCheckstyle) {
diff --git a/src/main/config/checkstyle/checker.xml b/src/main/config/checkstyle/checker.xml
index 36eb786..444dc6e 100644
--- a/src/main/config/checkstyle/checker.xml
+++ b/src/main/config/checkstyle/checker.xml
@@ -32,21 +32,22 @@
 <module name="Checker">
   <property name="localeLanguage" value="en"/>
 
-  <property name="cacheFile" value="${cache_file}"/>
+  <!-- config_loc here is to workaround https://github.com/gradle/gradle/issues/13927 -->
+  <property name="cacheFile" value="${config_loc}/${cache_file}"/>
 
   <!-- Checks for headers -->
   <!-- See http://checkstyle.sf.net/config_header.html -->
     <!-- Verify that EVERY source file has the appropriate license -->
   <module name="Header">
-    <property name="headerFile" value="${base_dir}/src/main/config/checkstyle/header.java.txt"/>
+    <property name="headerFile" value="${config_loc}/header.java.txt"/>
     <property name="fileExtensions" value="cql,jj,json"/>
   </module>
   <module name="Header">
-    <property name="headerFile" value="${base_dir}/src/main/config/checkstyle/header.properties.txt"/>
+    <property name="headerFile" value="${config_loc}/header.properties.txt"/>
     <property name="fileExtensions" value="properties"/>
   </module>
   <module name="Header">
-    <property name="headerFile" value="${base_dir}/src/main/config/checkstyle/header.xml.txt"/>
+    <property name="headerFile" value="${config_loc}/header.xml.txt"/>
     <property name="fileExtensions" value="xml"/>
   </module>
 
@@ -289,6 +290,6 @@
   </module>
 
   <module name="SuppressionFilter">
-    <property name="file" value="${base_dir}/src/main/config/checkstyle/suppressions.xml"/>
+    <property name="file" value="${config_loc}/suppressions.xml"/>
   </module>
 </module>