You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2017/10/12 19:18:27 UTC
kudu git commit: java-client: enforce that only Java 7 APIs are used
Repository: kudu
Updated Branches:
refs/heads/master f373af07d -> b6f727ea2
java-client: enforce that only Java 7 APIs are used
The underlying enforcement machinery is powered by animal-sniffer, which has
both maven and gradle plugins. The maven plugin doesn't check test code [1],
but the gradle plugin does.
To test this, I added a Process.destroyForcibly() call to MiniKuduCluster,
which caused the gradle build to fail. I also added a
ConcurrentHashMap.keySet() call to Statistics (i.e. KUDU-2188), which caused
both builds to fail.
1. https://github.com/mojohaus/animal-sniffer/issues/5
Change-Id: I6ed072138fd42449a477647af4c0cf13b59a5c43
Reviewed-on: http://gerrit.cloudera.org:8080/8250
Reviewed-by: Grant Henke <gr...@gmail.com>
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/b6f727ea
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/b6f727ea
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/b6f727ea
Branch: refs/heads/master
Commit: b6f727ea29707c16e90f9d584ac8ae70ecf3050b
Parents: f373af0
Author: Adar Dembo <ad...@cloudera.com>
Authored: Tue Oct 10 13:40:43 2017 -0700
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Thu Oct 12 19:18:11 2017 +0000
----------------------------------------------------------------------
java/gradle.properties | 9 +++++++++
java/gradle/buildscript.gradle | 3 ++-
java/gradle/quality.gradle | 17 ++++++++++++++++-
java/pom.xml | 22 ++++++++++++++++++++++
4 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/b6f727ea/java/gradle.properties
----------------------------------------------------------------------
diff --git a/java/gradle.properties b/java/gradle.properties
index e25c49b..425dc1d 100755
--- a/java/gradle.properties
+++ b/java/gradle.properties
@@ -25,7 +25,16 @@ url = https://kudu.apache.org/
scmUrl = git://git.apache.org/kudu.git
issueTrackerUrl = https://issues.apache.org/jira/projects/KUDU
+# Version passed to javac's -source and -target parameters:
+#
+# -source Specifies the version of source code accepted.
+# -target Generate class files that target a specified version of the VM. Class
+# files will run on the specified target and on later versions, but not
+# on earlier versions of the VM.
+#
+# When changing this, also change the Java API signature defined in quality.gradle.
javaCompatibility = 1.7
+
encoding = UTF-8
# Maximum parallel forks to use while unit testing.
http://git-wip-us.apache.org/repos/asf/kudu/blob/b6f727ea/java/gradle/buildscript.gradle
----------------------------------------------------------------------
diff --git a/java/gradle/buildscript.gradle b/java/gradle/buildscript.gradle
index 8251d54..89827b3 100644
--- a/java/gradle/buildscript.gradle
+++ b/java/gradle/buildscript.gradle
@@ -34,4 +34,5 @@ dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.2"
classpath "com.netflix.nebula:nebula-clojure-plugin:4.1.0"
classpath "io.spring.gradle:propdeps-plugin:0.0.9.RELEASE"
-}
\ No newline at end of file
+ classpath "ru.vyarus:gradle-animalsniffer-plugin:1.4.2"
+}
http://git-wip-us.apache.org/repos/asf/kudu/blob/b6f727ea/java/gradle/quality.gradle
----------------------------------------------------------------------
diff --git a/java/gradle/quality.gradle b/java/gradle/quality.gradle
index 1f07597..7b0ad0c 100644
--- a/java/gradle/quality.gradle
+++ b/java/gradle/quality.gradle
@@ -21,6 +21,7 @@ apply plugin: "checkstyle" // Ensures Java code follows the defined coding style
apply plugin: "findbugs" // Performs static code analysis to look for bugs in Java code.
apply plugin: "pmd" // Performs static code analysis to look for common code smells 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.
checkstyle {
configFile = file("$rootDir/kudu_style.xml")
@@ -67,6 +68,20 @@ task pmd(dependsOn: [pmdMain, pmdTest, pmdIntegrationTest], group: "Verification
description = "Run PMD analysis."
}
+// Define a Java API signature for use by animal-sniffer. It'll enforce that all
+// Java API usage adheres to this signature.
+//
+// When changing this, also change javaCompatibility defined in gradle.properties.
+dependencies {
+ signature 'org.codehaus.mojo.signature:java17:1.0@signature'
+}
+
+// Create an aggregate animal-sniffer task.
+// This simplifies running animal-sniffer on all the code by only needing one task instead of multiple in your command.
+task animalsniffer(dependsOn: [animalsnifferMain, animalsnifferTest, animalsnifferIntegrationTest], group: "Verification") {
+ description = "Run animal-sniffer analysis."
+}
+
// Configure the versions plugin to only show dependency updates for released versions.
dependencyUpdates {
revision = "release"
@@ -82,4 +97,4 @@ dependencyUpdates {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/kudu/blob/b6f727ea/java/pom.xml
----------------------------------------------------------------------
diff --git a/java/pom.xml b/java/pom.xml
index b789b42..e341456 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -322,6 +322,28 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <!-- Enforce that all of our code uses Java 7 and not Java 8 APIs. -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <version>1.16</version>
+ <configuration>
+ <signature>
+ <groupId>org.codehaus.mojo.signature</groupId>
+ <artifactId>java17</artifactId>
+ <version>1.0</version>
+ </signature>
+ </configuration>
+ <executions>
+ <execution>
+ <id>check-java7-apis</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>