Refactor Gradle project setup

Make root build.gradle easier to read:
- Moved appengine war-assembly into separate script
- Moved java static analysis configs to separate script,
  for easier sharing with buildSrc folder.

Update Gradle config in the buildSrc folder:
- Applied static analysis, and cleaned up a few style and
  dependency lint errors.
- Added dependency locks
- Set up Google java format enforcement (Spotless)
  since this is new code.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246858172
This commit is contained in:
weiminyu 2019-05-06 11:03:37 -07:00 committed by jianglai
parent f516371ba6
commit 7577fbdbd4
18 changed files with 732 additions and 140 deletions

View file

@ -0,0 +1,73 @@
def environments = ['production', 'sandbox', 'alpha', 'crash']
def projects = ['production': 'domain-registry',
'sandbox' : 'domain-registry-sandbox',
'alpha' : 'domain-registry-alpha',
'crash' : 'domain-registry-crash']
def environment = rootProject.findProperty("environment")
if (environment == null) {
environment = 'alpha'
}
def gcpProject = projects[environment]
if (gcpProject == null) {
throw new GradleException("-Penvironment must be one of ${environments}.")
}
apply plugin: 'war'
// Set this directory before applying the appengine plugin so that the
// plugin will recognize this as an app-engine standard app (and also
// obtains the appengine-web.xml from the correct location)
project.convention.plugins['war'].webAppDirName =
"../../../java/google/registry/env/${environment}/${project.name}"
apply plugin: 'com.google.cloud.tools.appengine'
// Get the web.xml file for the service.
war {
webInf {
from "../../../java/google/registry/env/common/${project.name}/WEB-INF"
}
}
def coreResourcesDir = "${rootDir}/core/build/resources/main"
war {
from("${coreResourcesDir}/google/registry/ui/html") {
include "*.html"
}
}
if (project.path == ":services:default") {
war {
from("${coreResourcesDir}/google/registry/ui") {
include "registrar_bin.js"
if (environment != "production") {
include "registrar_bin.js.map"
}
into("assets/js")
}
from("${coreResourcesDir}/google/registry/ui/css") {
include "registrar*"
into("assets/css")
}
from("${coreResourcesDir}/google/registry/ui/assets/images") {
include "**/*"
into("assets/images")
}
}
}
appengine {
deploy {
project = gcpProject
}
}
dependencies {
compile project(':core')
}
rootProject.deploy.dependsOn appengineDeploy
rootProject.stage.dependsOn appengineStage

View file

@ -13,12 +13,16 @@ buildscript {
} }
plugins { plugins {
// Java static analysis plugins. Keep versions consistent with
// ./buildSrc/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. // TODO(weiminyu): consider remove net.ltgt.apt. Gradle 5.2+
// Ensures that source code is generated at an appropriate location. // has similar functionalities.
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'
// NodeJs plugin
id "com.moowork.node" version "1.2.0" id "com.moowork.node" version "1.2.0"
} }
@ -155,128 +159,16 @@ subprojects {
':services:tools', ':services:tools',
':services:pubapi'] ':services:pubapi']
def environments = ['production', 'sandbox', 'alpha', 'crash']
def projects = ['production': 'domain-registry',
'sandbox' : 'domain-registry-sandbox',
'alpha' : 'domain-registry-alpha',
'crash' : 'domain-registry-crash']
// Set up all of the deployment projects. // Set up all of the deployment projects.
if (services.contains(project.path)) { if (services.contains(project.path)) {
def environment = rootProject.findProperty("environment") apply from: "${rootDir.path}/appengine_war.gradle"
if (environment == null) {
environment = 'alpha'
}
def gcpProject = projects[environment]
if (gcpProject == null) {
throw new GradleException("-Penvironment must be one of ${environments}.")
}
apply plugin: 'war'
// Set this directory before applying the appengine plugin so that the
// plugin will recognize this as an app-engine standard app (and also
// obtains the appengine-web.xml from the correct location)
project.convention.plugins['war'].webAppDirName =
"../../../java/google/registry/env/${environment}/${project.name}"
apply plugin: 'com.google.cloud.tools.appengine'
// Get the web.xml file for the service.
war {
webInf {
from "../../../java/google/registry/env/common/${project.name}/WEB-INF"
}
}
def coreResourcesDir = "${rootDir}/core/build/resources/main"
war {
from("${coreResourcesDir}/google/registry/ui/html") {
include "*.html"
}
}
if (project.path == ":services:default") {
war {
from("${coreResourcesDir}/google/registry/ui") {
include "registrar_bin.js"
if (environment != "production") {
include "registrar_bin.js.map"
}
into("assets/js")
}
from("${coreResourcesDir}/google/registry/ui/css") {
include "registrar*"
into("assets/css")
}
from("${coreResourcesDir}/google/registry/ui/assets/images") {
include "**/*"
into("assets/images")
}
}
}
appengine {
deploy {
project = gcpProject
}
}
dependencies {
compile project(':core')
}
rootProject.deploy.dependsOn appengineDeploy
rootProject.stage.dependsOn appengineStage
// Return early, do not apply the settings below. // Return early, do not apply the settings below.
return return
} }
apply plugin: 'java' apply from: "${rootDir.path}/java_common.gradle"
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.3")
}
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'
targetCompatibility = '1.8'
compileJava { options.encoding = "UTF-8" }
compileTestJava { options.encoding = "UTF-8" }
gradleLint.rules = [
// Checks if Gradle wrapper is up-to-date
'archaic-wrapper',
// Checks for indirect dependencies with dynamic version spec. Best
// practice calls for declaring them with specific versions.
'undeclared-dependency',
'unused-dependency'
// TODO(weiminyu): enable more dependency checks
]
if (project.name == 'third_party') return if (project.name == 'third_party') return

View file

@ -1,3 +1,26 @@
buildscript {
// Lock buildscript dependencies.
configurations.classpath {
resolutionStrategy.activateDependencyLocking()
}
}
plugins {
// Java static analysis plugins. Keep versions consistent with ../build.gradle
id 'nebula.lint' version '10.4.2'
// Config helper for annotation processors such as AutoValue and Dagger.
// Ensures that source code is generated at an appropriate location.
id 'net.ltgt.apt' version '0.19' apply false
id 'net.ltgt.errorprone' version '0.6.1'
id 'checkstyle'
id 'com.diffplug.gradle.spotless' version '3.18.0'
}
// Lock application dependencies.
dependencyLocking {
lockAllConfigurations()
}
repositories { repositories {
if (project.ext.properties.mavenUrl == null) { if (project.ext.properties.mavenUrl == null) {
@ -12,10 +35,33 @@ repositories {
} }
apply from: '../dependencies.gradle' apply from: '../dependencies.gradle'
apply from: '../java_common.gradle'
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 {
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-oauth2-http']
compile deps['com.google.cloud:google-cloud-core']
compile deps['com.google.guava:guava'] compile deps['com.google.guava:guava']
compile deps['com.google.auto.value:auto-value-annotations'] compile deps['com.google.auto.value:auto-value-annotations']
compile deps['com.google.cloud:google-cloud-storage'] compile deps['com.google.cloud:google-cloud-storage']
@ -25,6 +71,7 @@ dependencies {
annotationProcessor deps['com.google.auto.value:auto-value'] annotationProcessor deps['com.google.auto.value:auto-value']
testCompile deps['com.google.truth:truth'] testCompile deps['com.google.truth:truth']
testCompile deps['com.google.truth.extensions:truth-java8-extension'] testCompile deps['com.google.truth.extensions:truth-java8-extension']
testCompile deps['junit:junit']
testCompile deps['org.mockito:mockito-core'] testCompile deps['org.mockito:mockito-core']
} }

View file

@ -0,0 +1,25 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.github.kevinstern:software-and-algorithms:1.0
com.github.stephenc.jcip:jcip-annotations:1.0-1
com.google.auto.value:auto-value:1.6.2
com.google.auto:auto-common:0.10
com.google.code.findbugs:jFormatString:3.0.0
com.google.code.findbugs:jsr305:3.0.2
com.google.errorprone:error_prone_annotation:2.3.3
com.google.errorprone:error_prone_annotations:2.3.3
com.google.errorprone:error_prone_check_api:2.3.3
com.google.errorprone:error_prone_core:2.3.3
com.google.errorprone:error_prone_type_annotations:2.3.3
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.0.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.j2objc:j2objc-annotations:1.1
com.google.protobuf:protobuf-java:3.4.0
com.googlecode.java-diff-utils:diffutils:1.3.0
org.checkerframework:checker-qual:2.5.3
org.checkerframework:dataflow:2.5.3
org.checkerframework:javacutil:2.5.3
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.pcollections:pcollections:2.1.2

View file

@ -0,0 +1,66 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
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.google.guava:guava:19.0
com.googlecode.concurrent-trees:concurrent-trees:2.6.1
com.googlecode.javaewah:JavaEWAH:1.1.6
com.jcraft:jsch:0.1.54
com.jcraft:jzlib:1.1.1
com.netflix.nebula:gradle-lint-plugin:10.4.2
com.netflix.nebula:nebula-gradle-interop:1.0.7
com.netflix.nebula:nebula-test:7.2.4
commons-codec:commons-codec:1.9
commons-io:commons-io:2.5
commons-lang:commons-lang:2.6
commons-logging:commons-logging:1.2
junit:junit:4.12
log4j:log4j:1.2.14
nebula.lint:nebula.lint.gradle.plugin:10.4.2
net.ltgt.apt:net.ltgt.apt.gradle.plugin:0.19
net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:0.6.1
net.ltgt.gradle:gradle-apt-plugin:0.19
net.ltgt.gradle:gradle-errorprone-plugin:0.6.1
org.apache.ant:ant-antlr:1.8.4
org.apache.ant:ant-junit:1.8.4
org.apache.ant:ant-launcher:1.8.4
org.apache.ant:ant:1.8.4
org.apache.commons:commons-lang3:3.8.1
org.apache.httpcomponents:httpclient:4.5.2
org.apache.httpcomponents:httpcore:4.4.4
org.apache.maven:maven-artifact:3.6.1
org.apache.maven:maven-builder-support:3.6.1
org.apache.maven:maven-model-builder:3.6.1
org.apache.maven:maven-model:3.6.1
org.codehaus.gpars:gpars:1.2.1
org.codehaus.groovy:groovy-all:2.4.9
org.codehaus.groovy:groovy-ant:2.1.8
org.codehaus.groovy:groovy-groovydoc:2.1.8
org.codehaus.groovy:groovy-templates:2.1.8
org.codehaus.groovy:groovy-xml:2.4.7
org.codehaus.groovy:groovy:2.4.7
org.codehaus.jsr166-mirror:jsr166y:1.7.0
org.codehaus.plexus:plexus-component-annotations:1.7.1
org.codehaus.plexus:plexus-interpolation:1.25
org.codehaus.plexus:plexus-utils:3.2.0
org.codenarc:CodeNarc:0.25.2
org.eclipse.jdt:core:3.1.1
org.eclipse.jgit:org.eclipse.jgit:5.0.1.201806211838-r
org.gmetrics:GMetrics:0.7
org.hamcrest:hamcrest-core:1.3
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.11
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.11
org.jetbrains.kotlin:kotlin-stdlib:1.3.11
org.jetbrains:annotations:13.0
org.multiverse:multiverse-core:0.7.0
org.objenesis:objenesis:2.4
org.ow2.asm:asm:7.0
org.slf4j:slf4j-api:1.7.2
org.spockframework:spock-core:1.1-groovy-2.4-rc-4

View file

@ -0,0 +1,18 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
antlr:antlr:2.7.7
com.google.code.findbugs:jsr305:3.0.2
com.google.errorprone:error_prone_annotations:2.2.0
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.0.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.j2objc:j2objc-annotations:1.1
com.puppycrawl.tools:checkstyle:8.17
commons-beanutils:commons-beanutils:1.9.3
commons-collections:commons-collections:3.2.2
info.picocli:picocli:3.9.0
net.sf.saxon:Saxon-HE:9.9.0-2
org.antlr:antlr4-runtime:4.7.2
org.checkerframework:checker-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17

View file

@ -0,0 +1,61 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
aopalliance:aopalliance:1.0
args4j:args4j:2.0.23
com.fasterxml.jackson.core:jackson-core:2.9.6
com.google.api-client:google-api-client:1.27.0
com.google.api.grpc:proto-google-common-protos:1.12.0
com.google.api.grpc:proto-google-iam-v1:0.12.0
com.google.api:api-common:1.7.0
com.google.api:gax-httpjson:0.52.1
com.google.api:gax:1.35.1
com.google.apis:google-api-services-storage:v1-rev20181013-1.27.0
com.google.auth:google-auth-library-credentials:0.12.0
com.google.auth:google-auth-library-oauth2-http:0.12.0
com.google.auto.value:auto-value-annotations:1.6.2
com.google.cloud:google-cloud-core-http:1.59.0
com.google.cloud:google-cloud-core:1.59.0
com.google.cloud:google-cloud-storage:1.59.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.7
com.google.common.html.types:types:1.0.4
com.google.errorprone:error_prone_annotations:2.2.0
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.gwt:gwt-user:2.8.0-beta1
com.google.http-client:google-http-client-appengine:1.27.0
com.google.http-client:google-http-client-jackson2:1.27.0
com.google.http-client:google-http-client:1.27.0
com.google.inject.extensions:guice-multibindings:4.1.0
com.google.inject:guice:4.1.0
com.google.j2objc:j2objc-annotations:1.1
com.google.oauth-client:google-oauth-client:1.27.0
com.google.protobuf:protobuf-java-util:3.6.1
com.google.protobuf:protobuf-java:3.6.1
com.google.template:soy:2018-03-14
com.ibm.icu:icu4j:57.1
commons-codec:commons-codec:1.10
commons-logging:commons-logging:1.2
io.grpc:grpc-context:1.12.0
io.opencensus:opencensus-api:0.15.0
io.opencensus:opencensus-contrib-http-util:0.15.0
javax.annotation:javax.annotation-api:1.2
javax.annotation:jsr250-api:1.0
javax.inject:javax.inject:1
javax.validation:validation-api:1.0.0.GA
joda-time:joda-time:2.9.2
org.apache.commons:commons-lang3:3.8.1
org.apache.commons:commons-text:1.6
org.apache.httpcomponents:httpclient:4.5.5
org.apache.httpcomponents:httpcore:4.4.9
org.checkerframework:checker-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.json:json:20160212
org.ow2.asm:asm-analysis:6.0
org.ow2.asm:asm-commons:6.0
org.ow2.asm:asm-tree:6.0
org.ow2.asm:asm-util:6.0
org.ow2.asm:asm:6.0
org.threeten:threetenbp:1.3.3

View file

@ -0,0 +1,61 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
aopalliance:aopalliance:1.0
args4j:args4j:2.0.23
com.fasterxml.jackson.core:jackson-core:2.9.6
com.google.api-client:google-api-client:1.27.0
com.google.api.grpc:proto-google-common-protos:1.12.0
com.google.api.grpc:proto-google-iam-v1:0.12.0
com.google.api:api-common:1.7.0
com.google.api:gax-httpjson:0.52.1
com.google.api:gax:1.35.1
com.google.apis:google-api-services-storage:v1-rev20181013-1.27.0
com.google.auth:google-auth-library-credentials:0.12.0
com.google.auth:google-auth-library-oauth2-http:0.12.0
com.google.auto.value:auto-value-annotations:1.6.2
com.google.cloud:google-cloud-core-http:1.59.0
com.google.cloud:google-cloud-core:1.59.0
com.google.cloud:google-cloud-storage:1.59.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.7
com.google.common.html.types:types:1.0.4
com.google.errorprone:error_prone_annotations:2.2.0
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.gwt:gwt-user:2.8.0-beta1
com.google.http-client:google-http-client-appengine:1.27.0
com.google.http-client:google-http-client-jackson2:1.27.0
com.google.http-client:google-http-client:1.27.0
com.google.inject.extensions:guice-multibindings:4.1.0
com.google.inject:guice:4.1.0
com.google.j2objc:j2objc-annotations:1.1
com.google.oauth-client:google-oauth-client:1.27.0
com.google.protobuf:protobuf-java-util:3.6.1
com.google.protobuf:protobuf-java:3.6.1
com.google.template:soy:2018-03-14
com.ibm.icu:icu4j:57.1
commons-codec:commons-codec:1.10
commons-logging:commons-logging:1.2
io.grpc:grpc-context:1.12.0
io.opencensus:opencensus-api:0.15.0
io.opencensus:opencensus-contrib-http-util:0.15.0
javax.annotation:javax.annotation-api:1.2
javax.annotation:jsr250-api:1.0
javax.inject:javax.inject:1
javax.validation:validation-api:1.0.0.GA
joda-time:joda-time:2.9.2
org.apache.commons:commons-lang3:3.8.1
org.apache.commons:commons-text:1.6
org.apache.httpcomponents:httpclient:4.5.5
org.apache.httpcomponents:httpcore:4.4.9
org.checkerframework:checker-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.json:json:20160212
org.ow2.asm:asm-analysis:6.0
org.ow2.asm:asm-commons:6.0
org.ow2.asm:asm-tree:6.0
org.ow2.asm:asm-util:6.0
org.ow2.asm:asm:6.0
org.threeten:threetenbp:1.3.3

View file

@ -0,0 +1,4 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.google.errorprone:javac:9+181-r4173-1

View file

@ -0,0 +1,61 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
aopalliance:aopalliance:1.0
args4j:args4j:2.0.23
com.fasterxml.jackson.core:jackson-core:2.9.6
com.google.api-client:google-api-client:1.27.0
com.google.api.grpc:proto-google-common-protos:1.12.0
com.google.api.grpc:proto-google-iam-v1:0.12.0
com.google.api:api-common:1.7.0
com.google.api:gax-httpjson:0.52.1
com.google.api:gax:1.35.1
com.google.apis:google-api-services-storage:v1-rev20181013-1.27.0
com.google.auth:google-auth-library-credentials:0.12.0
com.google.auth:google-auth-library-oauth2-http:0.12.0
com.google.auto.value:auto-value-annotations:1.6.2
com.google.cloud:google-cloud-core-http:1.59.0
com.google.cloud:google-cloud-core:1.59.0
com.google.cloud:google-cloud-storage:1.59.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.7
com.google.common.html.types:types:1.0.4
com.google.errorprone:error_prone_annotations:2.2.0
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.gwt:gwt-user:2.8.0-beta1
com.google.http-client:google-http-client-appengine:1.27.0
com.google.http-client:google-http-client-jackson2:1.27.0
com.google.http-client:google-http-client:1.27.0
com.google.inject.extensions:guice-multibindings:4.1.0
com.google.inject:guice:4.1.0
com.google.j2objc:j2objc-annotations:1.1
com.google.oauth-client:google-oauth-client:1.27.0
com.google.protobuf:protobuf-java-util:3.6.1
com.google.protobuf:protobuf-java:3.6.1
com.google.template:soy:2018-03-14
com.ibm.icu:icu4j:57.1
commons-codec:commons-codec:1.10
commons-logging:commons-logging:1.2
io.grpc:grpc-context:1.12.0
io.opencensus:opencensus-api:0.15.0
io.opencensus:opencensus-contrib-http-util:0.15.0
javax.annotation:javax.annotation-api:1.2
javax.annotation:jsr250-api:1.0
javax.inject:javax.inject:1
javax.validation:validation-api:1.0.0.GA
joda-time:joda-time:2.9.2
org.apache.commons:commons-lang3:3.8.1
org.apache.commons:commons-text:1.6
org.apache.httpcomponents:httpclient:4.5.5
org.apache.httpcomponents:httpcore:4.4.9
org.checkerframework:checker-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.json:json:20160212
org.ow2.asm:asm-analysis:6.0
org.ow2.asm:asm-commons:6.0
org.ow2.asm:asm-tree:6.0
org.ow2.asm:asm-util:6.0
org.ow2.asm:asm:6.0
org.threeten:threetenbp:1.3.3

View file

@ -0,0 +1,24 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.github.kevinstern:software-and-algorithms:1.0
com.github.stephenc.jcip:jcip-annotations:1.0-1
com.google.auto:auto-common:0.10
com.google.code.findbugs:jFormatString:3.0.0
com.google.code.findbugs:jsr305:3.0.2
com.google.errorprone:error_prone_annotation:2.3.3
com.google.errorprone:error_prone_annotations:2.3.3
com.google.errorprone:error_prone_check_api:2.3.3
com.google.errorprone:error_prone_core:2.3.3
com.google.errorprone:error_prone_type_annotations:2.3.3
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.0.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.j2objc:j2objc-annotations:1.1
com.google.protobuf:protobuf-java:3.4.0
com.googlecode.java-diff-utils:diffutils:1.3.0
org.checkerframework:checker-qual:2.5.3
org.checkerframework:dataflow:2.5.3
org.checkerframework:javacutil:2.5.3
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.pcollections:pcollections:2.1.2

View file

@ -0,0 +1,71 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
aopalliance:aopalliance:1.0
args4j:args4j:2.0.23
com.fasterxml.jackson.core:jackson-core:2.9.6
com.google.api-client:google-api-client:1.27.0
com.google.api.grpc:proto-google-common-protos:1.12.0
com.google.api.grpc:proto-google-iam-v1:0.12.0
com.google.api:api-common:1.7.0
com.google.api:gax-httpjson:0.52.1
com.google.api:gax:1.35.1
com.google.apis:google-api-services-storage:v1-rev20181013-1.27.0
com.google.auth:google-auth-library-credentials:0.12.0
com.google.auth:google-auth-library-oauth2-http:0.12.0
com.google.auto.value:auto-value-annotations:1.6.3
com.google.cloud:google-cloud-core-http:1.59.0
com.google.cloud:google-cloud-core:1.59.0
com.google.cloud:google-cloud-storage:1.59.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.7
com.google.common.html.types:types:1.0.4
com.google.errorprone:error_prone_annotations:2.3.1
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.gwt:gwt-user:2.8.0-beta1
com.google.http-client:google-http-client-appengine:1.27.0
com.google.http-client:google-http-client-jackson2:1.27.0
com.google.http-client:google-http-client:1.27.0
com.google.inject.extensions:guice-multibindings:4.1.0
com.google.inject:guice:4.1.0
com.google.j2objc:j2objc-annotations:1.1
com.google.oauth-client:google-oauth-client:1.27.0
com.google.protobuf:protobuf-java-util:3.6.1
com.google.protobuf:protobuf-java:3.6.1
com.google.template:soy:2018-03-14
com.google.truth.extensions:truth-java8-extension:0.44
com.google.truth:truth:0.44
com.googlecode.java-diff-utils:diffutils:1.3.0
com.ibm.icu:icu4j:57.1
commons-codec:commons-codec:1.10
commons-logging:commons-logging:1.2
io.grpc:grpc-context:1.12.0
io.opencensus:opencensus-api:0.15.0
io.opencensus:opencensus-contrib-http-util:0.15.0
javax.annotation:javax.annotation-api:1.2
javax.annotation:jsr250-api:1.0
javax.inject:javax.inject:1
javax.validation:validation-api:1.0.0.GA
joda-time:joda-time:2.9.2
junit:junit:4.12
net.bytebuddy:byte-buddy-agent:1.9.7
net.bytebuddy:byte-buddy:1.9.7
org.apache.commons:commons-lang3:3.8.1
org.apache.commons:commons-text:1.6
org.apache.httpcomponents:httpclient:4.5.5
org.apache.httpcomponents:httpcore:4.4.9
org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.hamcrest:hamcrest-core:1.3
org.json:json:20160212
org.mockito:mockito-core:2.25.0
org.objenesis:objenesis:2.6
org.ow2.asm:asm-analysis:6.0
org.ow2.asm:asm-commons:6.0
org.ow2.asm:asm-tree:6.0
org.ow2.asm:asm-util:6.0
org.ow2.asm:asm:6.0
org.threeten:threetenbp:1.3.3

View file

@ -0,0 +1,71 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
aopalliance:aopalliance:1.0
args4j:args4j:2.0.23
com.fasterxml.jackson.core:jackson-core:2.9.6
com.google.api-client:google-api-client:1.27.0
com.google.api.grpc:proto-google-common-protos:1.12.0
com.google.api.grpc:proto-google-iam-v1:0.12.0
com.google.api:api-common:1.7.0
com.google.api:gax-httpjson:0.52.1
com.google.api:gax:1.35.1
com.google.apis:google-api-services-storage:v1-rev20181013-1.27.0
com.google.auth:google-auth-library-credentials:0.12.0
com.google.auth:google-auth-library-oauth2-http:0.12.0
com.google.auto.value:auto-value-annotations:1.6.3
com.google.cloud:google-cloud-core-http:1.59.0
com.google.cloud:google-cloud-core:1.59.0
com.google.cloud:google-cloud-storage:1.59.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.7
com.google.common.html.types:types:1.0.4
com.google.errorprone:error_prone_annotations:2.3.1
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.gwt:gwt-user:2.8.0-beta1
com.google.http-client:google-http-client-appengine:1.27.0
com.google.http-client:google-http-client-jackson2:1.27.0
com.google.http-client:google-http-client:1.27.0
com.google.inject.extensions:guice-multibindings:4.1.0
com.google.inject:guice:4.1.0
com.google.j2objc:j2objc-annotations:1.1
com.google.oauth-client:google-oauth-client:1.27.0
com.google.protobuf:protobuf-java-util:3.6.1
com.google.protobuf:protobuf-java:3.6.1
com.google.template:soy:2018-03-14
com.google.truth.extensions:truth-java8-extension:0.44
com.google.truth:truth:0.44
com.googlecode.java-diff-utils:diffutils:1.3.0
com.ibm.icu:icu4j:57.1
commons-codec:commons-codec:1.10
commons-logging:commons-logging:1.2
io.grpc:grpc-context:1.12.0
io.opencensus:opencensus-api:0.15.0
io.opencensus:opencensus-contrib-http-util:0.15.0
javax.annotation:javax.annotation-api:1.2
javax.annotation:jsr250-api:1.0
javax.inject:javax.inject:1
javax.validation:validation-api:1.0.0.GA
joda-time:joda-time:2.9.2
junit:junit:4.12
net.bytebuddy:byte-buddy-agent:1.9.7
net.bytebuddy:byte-buddy:1.9.7
org.apache.commons:commons-lang3:3.8.1
org.apache.commons:commons-text:1.6
org.apache.httpcomponents:httpclient:4.5.5
org.apache.httpcomponents:httpcore:4.4.9
org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.hamcrest:hamcrest-core:1.3
org.json:json:20160212
org.mockito:mockito-core:2.25.0
org.objenesis:objenesis:2.6
org.ow2.asm:asm-analysis:6.0
org.ow2.asm:asm-commons:6.0
org.ow2.asm:asm-tree:6.0
org.ow2.asm:asm-util:6.0
org.ow2.asm:asm:6.0
org.threeten:threetenbp:1.3.3

View file

@ -0,0 +1,71 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
aopalliance:aopalliance:1.0
args4j:args4j:2.0.23
com.fasterxml.jackson.core:jackson-core:2.9.6
com.google.api-client:google-api-client:1.27.0
com.google.api.grpc:proto-google-common-protos:1.12.0
com.google.api.grpc:proto-google-iam-v1:0.12.0
com.google.api:api-common:1.7.0
com.google.api:gax-httpjson:0.52.1
com.google.api:gax:1.35.1
com.google.apis:google-api-services-storage:v1-rev20181013-1.27.0
com.google.auth:google-auth-library-credentials:0.12.0
com.google.auth:google-auth-library-oauth2-http:0.12.0
com.google.auto.value:auto-value-annotations:1.6.3
com.google.cloud:google-cloud-core-http:1.59.0
com.google.cloud:google-cloud-core:1.59.0
com.google.cloud:google-cloud-storage:1.59.0
com.google.code.findbugs:jsr305:3.0.2
com.google.code.gson:gson:2.7
com.google.common.html.types:types:1.0.4
com.google.errorprone:error_prone_annotations:2.3.1
com.google.guava:failureaccess:1.0.1
com.google.guava:guava:27.1-jre
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
com.google.gwt:gwt-user:2.8.0-beta1
com.google.http-client:google-http-client-appengine:1.27.0
com.google.http-client:google-http-client-jackson2:1.27.0
com.google.http-client:google-http-client:1.27.0
com.google.inject.extensions:guice-multibindings:4.1.0
com.google.inject:guice:4.1.0
com.google.j2objc:j2objc-annotations:1.1
com.google.oauth-client:google-oauth-client:1.27.0
com.google.protobuf:protobuf-java-util:3.6.1
com.google.protobuf:protobuf-java:3.6.1
com.google.template:soy:2018-03-14
com.google.truth.extensions:truth-java8-extension:0.44
com.google.truth:truth:0.44
com.googlecode.java-diff-utils:diffutils:1.3.0
com.ibm.icu:icu4j:57.1
commons-codec:commons-codec:1.10
commons-logging:commons-logging:1.2
io.grpc:grpc-context:1.12.0
io.opencensus:opencensus-api:0.15.0
io.opencensus:opencensus-contrib-http-util:0.15.0
javax.annotation:javax.annotation-api:1.2
javax.annotation:jsr250-api:1.0
javax.inject:javax.inject:1
javax.validation:validation-api:1.0.0.GA
joda-time:joda-time:2.9.2
junit:junit:4.12
net.bytebuddy:byte-buddy-agent:1.9.7
net.bytebuddy:byte-buddy:1.9.7
org.apache.commons:commons-lang3:3.8.1
org.apache.commons:commons-text:1.6
org.apache.httpcomponents:httpclient:4.5.5
org.apache.httpcomponents:httpcore:4.4.9
org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.5.2
org.codehaus.mojo:animal-sniffer-annotations:1.17
org.hamcrest:hamcrest-core:1.3
org.json:json:20160212
org.mockito:mockito-core:2.25.0
org.objenesis:objenesis:2.6
org.ow2.asm:asm-analysis:6.0
org.ow2.asm:asm-commons:6.0
org.ow2.asm:asm-tree:6.0
org.ow2.asm:asm-util:6.0
org.ow2.asm:asm:6.0
org.threeten:threetenbp:1.3.3

View file

@ -50,9 +50,7 @@ import org.gradle.api.reporting.ReportContainer;
import org.gradle.api.reporting.Reporting; import org.gradle.api.reporting.Reporting;
import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskAction;
/** /** A task that uploads the Reports generated by other tasks to GCS. */
* A task that uploads the Reports generated by other tasks to GCS.
*/
public class ReportUploader extends DefaultTask { public class ReportUploader extends DefaultTask {
private static final SecureRandom SECURE_RANDOM = new SecureRandom(); private static final SecureRandom SECURE_RANDOM = new SecureRandom();
@ -69,13 +67,15 @@ public class ReportUploader extends DefaultTask {
private String credentialsFile = null; private String credentialsFile = null;
private String multithreadedUpload = null; private String multithreadedUpload = null;
/** Sets the destination of the reports. /**
* Sets the destination of the reports.
* *
* Currently supports two types of destinations: * <p>Currently supports two types of destinations:
* *
* - file://[absulute local path], e.g. file:///tmp/buildOutputs/ * <ul>
* * <li>file://[absulute local path], e.g. file:///tmp/buildOutputs/
* - gcs://[bucket name]/[optional path], e.g. gcs://my-bucket/buildOutputs/ * <li>gcs://[bucket name]/[optional path], e.g. gcs://my-bucket/buildOutputs/
* </ul>
*/ */
public void setDestination(String destination) { public void setDestination(String destination) {
this.destination = destination; this.destination = destination;
@ -207,14 +207,12 @@ public class ReportUploader extends DefaultTask {
absoluteFolderName); absoluteFolderName);
FilesWithEntryPoint filesToUpload = generateFilesToUpload(); FilesWithEntryPoint filesToUpload = generateFilesToUpload();
System.out.format( System.out.format(
"ReportUploader: going to save %s files to %s\n", "ReportUploader: going to save %s files to %s\n", filesToUpload.files().size(), folder);
filesToUpload.files().size(), folder);
filesToUpload filesToUpload
.files() .files()
.forEach((path, dataSupplier) -> saveFile(folder.resolve(path), dataSupplier)); .forEach((path, dataSupplier) -> saveFile(folder.resolve(path), dataSupplier));
System.out.format( System.out.format(
"ReportUploader: report saved to file://%s\n", "ReportUploader: report saved to file://%s\n", folder.resolve(filesToUpload.entryPoint()));
folder.resolve(filesToUpload.entryPoint()));
} }
private void saveFile(Path path, Supplier<byte[]> dataSupplier) { private void saveFile(Path path, Supplier<byte[]> dataSupplier) {
@ -229,11 +227,9 @@ public class ReportUploader extends DefaultTask {
} }
} }
private void uploadResultsToGcs(String destination) { private void uploadResultsToGcs(String destination) {
checkArgument( checkArgument(
!destination.isEmpty(), !destination.isEmpty(), "destination must include at least the bucket name, but is empty");
"destination must include at least the bucket name, but is empty");
Path bucketWithFolder = Paths.get(destination, createUniqueFolderName()); Path bucketWithFolder = Paths.get(destination, createUniqueFolderName());
String bucket = bucketWithFolder.getName(0).toString(); String bucket = bucketWithFolder.getName(0).toString();
Path folder = bucketWithFolder.subpath(1, bucketWithFolder.getNameCount()); Path folder = bucketWithFolder.subpath(1, bucketWithFolder.getNameCount());
@ -259,7 +255,9 @@ public class ReportUploader extends DefaultTask {
uploadFilesToGcsMultithread(storage, bucket, folder, filesToUpload.files()); uploadFilesToGcsMultithread(storage, bucket, folder, filesToUpload.files());
} else { } else {
System.out.format("ReportUploader: single threaded upload\n"); System.out.format("ReportUploader: single threaded upload\n");
filesToUpload.files().forEach( filesToUpload
.files()
.forEach(
(path, dataSupplier) -> { (path, dataSupplier) -> {
System.out.format("ReportUploader: Uploading %s\n", path); System.out.format("ReportUploader: Uploading %s\n", path);
uploadFileToGcs(storage, bucket, folder.resolve(path), dataSupplier); uploadFileToGcs(storage, bucket, folder.resolve(path), dataSupplier);

View file

@ -29,9 +29,15 @@ import org.gradle.api.Project;
*/ */
public class ReportUploaderPlugin implements Plugin<Project> { public class ReportUploaderPlugin implements Plugin<Project> {
@Override
public void apply(Project project) { public void apply(Project project) {
ReportUploader reportUploader = ReportUploader reportUploader =
project.getTasks().create("reportUploader", ReportUploader.class, task -> { project
.getTasks()
.create(
"reportUploader",
ReportUploader.class,
task -> {
task.setDescription("Uploads the reports to GCS bucket"); task.setDescription("Uploads the reports to GCS bucket");
task.setGroup("uploads"); task.setGroup("uploads");
}); });

View file

@ -36,6 +36,7 @@ ext {
'com.google.auto.value:auto-value:1.6.2', 'com.google.auto.value:auto-value:1.6.2',
'com.google.auto.value:auto-value-annotations:1.6.2', 'com.google.auto.value:auto-value-annotations:1.6.2',
'com.google.closure-stylesheets:closure-stylesheets:1.5.0', 'com.google.closure-stylesheets:closure-stylesheets:1.5.0',
'com.google.cloud:google-cloud-core:1.59.0',
'com.google.cloud:google-cloud-storage:1.59.0', 'com.google.cloud:google-cloud-storage:1.59.0',
'com.google.cloud.bigdataoss:gcsio:1.4.5', 'com.google.cloud.bigdataoss:gcsio:1.4.5',
'com.google.cloud.bigdataoss:util:1.4.5', 'com.google.cloud.bigdataoss:util:1.4.5',

42
gradle/java_common.gradle Normal file
View file

@ -0,0 +1,42 @@
apply plugin: 'java'
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.3")
}
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'
targetCompatibility = '1.8'
compileJava { options.encoding = "UTF-8" }
compileTestJava { options.encoding = "UTF-8" }
gradleLint.rules = [
// Checks if Gradle wrapper is up-to-date
'archaic-wrapper',
// Checks for indirect dependencies with dynamic version spec. Best
// practice calls for declaring them with specific versions.
'undeclared-dependency',
'unused-dependency'
// TODO(weiminyu): enable more dependency checks
]