Add Spotless to the Gradle build (#88)

* Add Spotless to the Gradle build

* spotless apply

* one dot instead of two
This commit is contained in:
gbrodman 2019-06-19 16:24:46 -04:00 committed by GitHub
parent ac82a5e4f1
commit 29d7cf7b9a
7 changed files with 35 additions and 32 deletions

View file

@ -29,6 +29,7 @@ plugins {
id "com.moowork.node" version "1.2.0" id "com.moowork.node" version "1.2.0"
id 'idea' id 'idea'
id 'com.diffplug.gradle.spotless' version '3.18.0'
} }
apply plugin: google.registry.gradle.plugin.ReportUploaderPlugin apply plugin: google.registry.gradle.plugin.ReportUploaderPlugin
@ -205,4 +206,3 @@ subprojects {
} }
} }
} }

View file

@ -8,14 +8,13 @@ buildscript {
} }
plugins { plugins {
// Java static analysis plugins. Keep versions consistent with ../build.gradle // Java static analysis plugins. Keep versions consistent with ../build.gradle
id 'nebula.lint' version '10.4.2' id 'nebula.lint' version '10.4.2'
// Config helper for annotation processors such as AutoValue and Dagger. // Config helper for annotation processors such as AutoValue and Dagger.
// Ensures that source code is generated at an appropriate location. // Ensures that source code is generated at an appropriate location.
id 'net.ltgt.apt' version '0.19' apply false id 'net.ltgt.apt' version '0.19' apply false
id 'net.ltgt.errorprone' version '0.6.1' id 'net.ltgt.errorprone' version '0.6.1'
id 'checkstyle' id 'checkstyle'
id 'com.diffplug.gradle.spotless' version '3.18.0' id 'com.diffplug.gradle.spotless' version '3.18.0'
} }
@ -53,26 +52,6 @@ checkstyle {
configDir file('../config/checkstyle') configDir file('../config/checkstyle')
} }
// To check or fix file formats, run the following commands from this directory:
// - Check: ../gradlew spotlessCheck
// - Format in place: ../gradlew spotlessApply
spotless {
java {
target project.fileTree("${project.rootDir}/") {
include "src/main/java/**/*.java"
include "src/test/java/**/*.java"
}
googleJavaFormat('1.7')
}
format 'misc', {
target '**/*.gradle'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
dependencies { dependencies {
def deps = dependencyMap def deps = dependencyMap
compile deps['com.google.auth:google-auth-library-credentials'] compile deps['com.google.auth:google-auth-library-credentials']

View file

@ -677,5 +677,3 @@ createUberJar('nomulus', 'nomulus', 'google.registry.tools.RegistryTool')
createUberJar('gtechTool', 'gtech_tool', 'google.registry.tools.GtechTool') createUberJar('gtechTool', 'gtech_tool', 'google.registry.tools.GtechTool')
project.nomulus.dependsOn project(':third_party').jar project.nomulus.dependsOn project(':third_party').jar
project.gtechTool.dependsOn project(':third_party').jar project.gtechTool.dependsOn project(':third_party').jar

View file

@ -158,4 +158,3 @@ ext {
[key, it] [key, it]
} }
} }

View file

@ -1,14 +1,21 @@
# This is a Gradle generated file for dependency locking. # This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised. # Manual edits can break the build and are not advised.
# This file is expected to be part of source control. # This file is expected to be part of source control.
antlr:antlr:2.7.7
cglib:cglib-nodep:3.2.2 cglib:cglib-nodep:3.2.2
com.diffplug.durian:durian-collect:1.2.0
com.diffplug.durian:durian-core:1.2.0
com.diffplug.durian:durian-io:1.2.0
com.diffplug.gradle.spotless:com.diffplug.gradle.spotless.gradle.plugin:3.18.0
com.diffplug.spotless:spotless-lib-extra:1.18.0
com.diffplug.spotless:spotless-lib:1.18.0
com.diffplug.spotless:spotless-plugin-gradle:3.18.0
com.github.jengelman.gradle.plugins:shadow:5.0.0 com.github.jengelman.gradle.plugins:shadow:5.0.0
com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:5.0.0 com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:5.0.0
com.google.cloud.tools:appengine-gradle-plugin:1.3.3 com.google.cloud.tools:appengine-gradle-plugin:1.3.3
com.google.cloud.tools:appengine-plugins-core:0.3.2 com.google.cloud.tools:appengine-plugins-core:0.3.2
com.google.code.gson:gson:2.7 com.google.code.gson:gson:2.7
com.google.guava:guava:20.0 com.google.guava:guava:20.0
com.googlecode.concurrent-trees:concurrent-trees:2.6.1
com.googlecode.javaewah:JavaEWAH:1.1.6 com.googlecode.javaewah:JavaEWAH:1.1.6
com.jcraft:jsch:0.1.54 com.jcraft:jsch:0.1.54
com.jcraft:jzlib:1.1.1 com.jcraft:jzlib:1.1.1
@ -46,8 +53,8 @@ org.codehaus.groovy:groovy-all:2.4.9
org.codehaus.groovy:groovy-ant:2.1.8 org.codehaus.groovy:groovy-ant:2.1.8
org.codehaus.groovy:groovy-groovydoc:2.1.8 org.codehaus.groovy:groovy-groovydoc:2.1.8
org.codehaus.groovy:groovy-templates:2.1.8 org.codehaus.groovy:groovy-templates:2.1.8
org.codehaus.groovy:groovy-xml:2.1.8 org.codehaus.groovy:groovy-xml:2.4.7
org.codehaus.groovy:groovy:2.1.8 org.codehaus.groovy:groovy:2.4.7
org.codehaus.jsr166-mirror:jsr166y:1.7.0 org.codehaus.jsr166-mirror:jsr166y:1.7.0
org.codehaus.plexus:plexus-component-annotations:1.7.1 org.codehaus.plexus:plexus-component-annotations:1.7.1
org.codehaus.plexus:plexus-interpolation:1.25 org.codehaus.plexus:plexus-interpolation:1.25
@ -67,7 +74,6 @@ org.objenesis:objenesis:2.4
org.ow2.asm:asm-analysis:7.0-beta org.ow2.asm:asm-analysis:7.0-beta
org.ow2.asm:asm-commons:7.0-beta org.ow2.asm:asm-commons:7.0-beta
org.ow2.asm:asm-tree:7.0-beta org.ow2.asm:asm-tree:7.0-beta
org.ow2.asm:asm-util:4.0
org.ow2.asm:asm:7.0 org.ow2.asm:asm:7.0
org.slf4j:slf4j-api:1.7.2 org.slf4j:slf4j-api:1.7.2
org.sonatype.aether:aether-api:1.13.1 org.sonatype.aether:aether-api:1.13.1

View file

@ -41,7 +41,6 @@ targetCompatibility = '1.8'
compileJava { options.encoding = "UTF-8" } compileJava { options.encoding = "UTF-8" }
compileTestJava { options.encoding = "UTF-8" } compileTestJava { options.encoding = "UTF-8" }
gradleLint.rules = [ gradleLint.rules = [
// Checks if Gradle wrapper is up-to-date // Checks if Gradle wrapper is up-to-date
'archaic-wrapper', 'archaic-wrapper',
@ -51,3 +50,26 @@ gradleLint.rules = [
'unused-dependency' 'unused-dependency'
// TODO(weiminyu): enable more dependency checks // TODO(weiminyu): enable more dependency checks
] ]
// To check or fix file formats, run the following commands from this directory:
// - Check: ./gradlew spotlessCheck
// - Format in place: ./gradlew spotlessApply
spotless {
java {
clearSteps()
target project.fileTree("${project.rootDir}/") {
include "src/main/java/**/*.java"
include "src/test/java/**/*.java"
// there are some files that have degenerate interactions with the GJF formatter
exclude "**/flows/FlowComponent.java"
}
googleJavaFormat('1.7')
}
format 'misc', {
clearSteps()
target '**/*.gradle'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}

View file

@ -59,4 +59,3 @@ dependencies {
annotationProcessor deps['com.google.dagger:dagger-compiler'] annotationProcessor deps['com.google.dagger:dagger-compiler']
testAnnotationProcessor deps['com.google.dagger:dagger-compiler'] testAnnotationProcessor deps['com.google.dagger:dagger-compiler']
} }