diff --git a/gradle/build.gradle b/gradle/build.gradle index 874108451..f76ba710c 100644 --- a/gradle/build.gradle +++ b/gradle/build.gradle @@ -6,6 +6,7 @@ buildscript { dependencies { classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3' + classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6.1" classpath 'org.sonatype.aether:aether-api:1.13.1' classpath 'org.sonatype.aether:aether-impl:1.13.1' } @@ -18,6 +19,8 @@ plugins { // Ensures that source code is generated at an appropriate location. id 'net.ltgt.apt' version '0.19' apply false id 'com.bmuschko.docker-java-application' version '4.0.4' apply false + id 'net.ltgt.errorprone' version '0.6.1' + id 'checkstyle' } apply from: 'dependencies.gradle' @@ -104,6 +107,27 @@ subprojects { apply plugin: 'nebula.dependency-lock' apply plugin: 'nebula.lint' apply plugin: 'net.ltgt.apt' + apply plugin: 'net.ltgt.errorprone' + apply plugin: 'checkstyle' + + // Checkstyle should run as part of the testing task + tasks.test.dependsOn tasks.checkstyleMain + tasks.test.dependsOn tasks.checkstyleTest + + dependencies { + // compatibility with Java 8 + errorproneJavac("com.google.errorprone:javac:9+181-r4173-1") + errorprone("com.google.errorprone:error_prone_core:2.3.2") + } + + tasks.withType(JavaCompile).configureEach { + options.compilerArgs << "-Werror" + options.errorprone.disableWarningsInGeneratedCode = true + options.errorprone.errorproneArgumentProviders.add([ + asArguments: { + return ['-XepExcludedPaths:.*/build/generated/.*'] + }] as CommandLineArgumentProvider) + } version = '1.0' sourceCompatibility = '1.8' diff --git a/gradle/config/checkstyle/checkstyle.xml b/gradle/config/checkstyle/checkstyle.xml new file mode 100644 index 000000000..5e8d60967 --- /dev/null +++ b/gradle/config/checkstyle/checkstyle.xml @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle/config/checkstyle/suppressions.xml b/gradle/config/checkstyle/suppressions.xml new file mode 100644 index 000000000..549987a53 --- /dev/null +++ b/gradle/config/checkstyle/suppressions.xml @@ -0,0 +1,12 @@ + + + + + + + + + +