kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject [kafka] branch trunk updated: KAFKA-7308: Fix rat and checkstyle config for Java 11 support (#5529)
Date Sat, 18 Aug 2018 15:18:36 GMT
This is an automated email from the ASF dual-hosted git repository.

ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b282b2a  KAFKA-7308: Fix rat and checkstyle config for Java 11 support (#5529)
b282b2a is described below

commit b282b2ab1073a04d33009865b4e9c600899bc2a0
Author: Ismael Juma <ismael@juma.me.uk>
AuthorDate: Sat Aug 18 08:18:28 2018 -0700

    KAFKA-7308: Fix rat and checkstyle config for Java 11 support (#5529)
    
    Relative paths in Gradle break when the Gradle daemon is used
    unless user.dir can be changed while the process is running.
    Java 11 disallows this, so we use project paths instead.
    
    Verified that rat and checkstyle work with Java 11 after these
    changes.
    
    Reviewers: Dong Lin <lindong28@gmail.com>
---
 build.gradle              | 16 +++++++++++-----
 checkstyle/checkstyle.xml |  4 ++--
 gradle/rat.gradle         | 15 ++++++---------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/build.gradle b/build.gradle
index f8dfeb7..0892ed1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -109,12 +109,12 @@ ext {
 
 apply from: file('wrapper.gradle')
 
-if (new File('.git').exists()) {
+if (file('.git').exists()) {
   apply from: file('gradle/rat.gradle')
   rat {
     // Exclude everything under the directory that git should be ignoring via .gitignore
or that isn't checked in. These
     // restrict us only to files that are checked in or are staged.
-    def repo = Grgit.open(project.file('.'))
+    def repo = Grgit.open(project.getRootDir())
     excludes = new ArrayList<String>(repo.clean(ignore: false, directories: true, dryRun:
true))
     // And some of the files that we have checked in should also be excluded from this check
     excludes.addAll([
@@ -359,7 +359,7 @@ subprojects {
 
   checkstyle {
     configFile = new File(rootDir, "checkstyle/checkstyle.xml")
-    configProperties = [importControlFile: "$rootDir/checkstyle/import-control.xml"]
+    configProperties = checkstyleConfigProperties("import-control.xml")
     toolVersion = '8.10'
   }
   test.dependsOn('checkstyleMain', 'checkstyleTest')
@@ -444,6 +444,12 @@ def fineTuneEclipseClasspathFile(eclipse, project) {
   }
 }
 
+def checkstyleConfigProperties(configFileName) {
+  [importControlFile: "$rootDir/checkstyle/$configFileName",
+   suppressionsFile: "$rootDir/checkstyle/suppressions.xml",
+   headerFile: "$rootDir/checkstyle/java.header"]
+}
+
 // Aggregates all jacoco results into the root project directory
 task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
   def javaProjects = subprojects.findAll { it.path != ':core' }
@@ -775,7 +781,7 @@ project(':core') {
   systemTestLibs.dependsOn('jar', 'testJar', 'copyDependantTestLibs')
 
   checkstyle {
-    configProperties = [importControlFile: "$rootDir/checkstyle/import-control-core.xml"]
+    configProperties = checkstyleConfigProperties("import-control-core.xml")
   }
 }
 
@@ -791,7 +797,7 @@ project(':examples') {
   }
 
   checkstyle {
-    configProperties = [importControlFile: "$rootDir/checkstyle/import-control-core.xml"]
+    configProperties = checkstyleConfigProperties("import-control-core.xml")
   }
 }
 
diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml
index 6eb1a82..13cfdb8 100644
--- a/checkstyle/checkstyle.xml
+++ b/checkstyle/checkstyle.xml
@@ -25,7 +25,7 @@
 
   <!-- header -->
   <module name="Header">
-    <property name="headerFile" value="checkstyle/java.header" />
+    <property name="headerFile" value="${headerFile}" />
   </module>
 
   <module name="TreeWalker">
@@ -137,6 +137,6 @@
   </module>
 
   <module name="SuppressionFilter">
-    <property name="file" value="checkstyle/suppressions.xml"/>
+    <property name="file" value="${suppressionsFile}"/>
   </module>
 </module>
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
index a51876c..513e952 100644
--- a/gradle/rat.gradle
+++ b/gradle/rat.gradle
@@ -17,9 +17,6 @@
  * under the License.
  */
 
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.gradle.api.Task
 import org.gradle.api.internal.project.IsolatedAntBuilder
 
 apply plugin: RatPlugin
@@ -28,18 +25,19 @@ class RatTask extends DefaultTask {
   @Input
   List<String> excludes
 
-  def reportPath = 'build/rat'
-  def stylesheet = 'gradle/resources/rat-output-to-html.xsl'
-  def xmlReport = reportPath + '/rat-report.xml'
-  def htmlReport = reportPath + '/rat-report.html'
+  def reportDir = project.file('build/rat')
+  def stylesheet = project.file('gradle/resources/rat-output-to-html.xsl').getAbsolutePath()
+  def xmlReport = new File(reportDir, 'rat-report.xml')
+  def htmlReport = new File(reportDir, 'rat-report.html')
 
   def generateXmlReport(File reportDir) {
     def antBuilder = services.get(IsolatedAntBuilder)
     def ratClasspath = project.configurations.rat
+    def projectPath = project.getRootDir().getAbsolutePath()
     antBuilder.withClasspath(ratClasspath).execute {
       ant.taskdef(resource: 'org/apache/rat/anttasks/antlib.xml')
       ant.report(format: 'xml', reportFile: xmlReport) {
-        fileset(dir: ".") {
+        fileset(dir: projectPath) {
           patternset {
             excludes.each {
               exclude(name: it)
@@ -80,7 +78,6 @@ class RatTask extends DefaultTask {
 
   @TaskAction
   def rat() {
-    File reportDir = new File(reportPath)
     if (!reportDir.exists()) {
       reportDir.mkdirs()
     }


Mime
View raw message