blob: b2848f7c2dccc2daab8c63178b876947d35ce394 [file] [log] [blame]
Manu Sridharan88bdd4a2017-08-15 14:30:41 -07001/*
2 * Copyright (C) 2017. Uber Technologies
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Thomas Broyer2cf80112018-10-17 21:19:38 +020017import net.ltgt.gradle.errorprone.CheckSeverity
Manu Sridharane43fc1e2020-02-13 12:34:00 -080018buildscript {
19 repositories {
20 google() // For Gradle 4.0+
21 }
Thomas Broyer2cf80112018-10-17 21:19:38 +020022
Manu Sridharane43fc1e2020-02-13 12:34:00 -080023 dependencies {
24 classpath 'com.android.tools.build:gradle:3.5.0'
25 }
26}
Manu Sridharanb4daf462017-09-26 14:03:26 -070027plugins {
Manu Sridharan01194cd2018-12-02 12:49:07 -080028 id "com.github.sherter.google-java-format" version "0.8"
Zac Sweers4d7b4d02019-04-08 08:34:06 -070029 id "net.ltgt.errorprone" version "0.7" apply false
Thomas Broyer2cf80112018-10-17 21:19:38 +020030 id "com.github.johnrengelman.shadow" version "2.0.4" apply false
Lázaro Clappeed3fc02021-01-05 14:27:41 -050031 id "com.github.nbaztec.coveralls-jacoco" version "1.2.5" apply false
32 id "com.android.application" version "3.5.0" apply false
Manu Sridharanb4daf462017-09-26 14:03:26 -070033}
34
35repositories {
36 // to get the google-java-format jar and dependencies
37 jcenter()
38}
39
Thomas Broyer2cf80112018-10-17 21:19:38 +020040apply from: "gradle/dependencies.gradle"
41
Manu Sridharan4c188132018-08-21 21:15:57 -070042subprojects { project ->
Thomas Broyer2cf80112018-10-17 21:19:38 +020043 project.apply plugin: "net.ltgt.errorprone"
44 project.dependencies {
45 errorprone deps.build.errorProneCore
46 errorproneJavac deps.build.errorProneJavac
Manu Sridharan4c188132018-08-21 21:15:57 -070047 }
Thomas Broyer2cf80112018-10-17 21:19:38 +020048 project.tasks.withType(JavaCompile) {
Lázaro Clapp8f06f382019-04-05 12:48:54 -040049 dependsOn(installGitHooks)
Thomas Broyer2cf80112018-10-17 21:19:38 +020050 options.compilerArgs += [
Lázaro Clappbf3de0f2020-06-24 12:38:46 -040051 "-Xlint:deprecation",
Thomas Broyer2cf80112018-10-17 21:19:38 +020052 "-Xlint:rawtypes",
Lázaro Clappbf3de0f2020-06-24 12:38:46 -040053 "-Xlint:unchecked",
Thomas Broyer2cf80112018-10-17 21:19:38 +020054 "-Werror"
55 ]
56 options.errorprone {
57 // disable warnings in generated code; AutoValue code fails UnnecessaryParentheses check
58 disableWarningsInGeneratedCode = true
Lázaro Clappbf3de0f2020-06-24 12:38:46 -040059 // Triggers for generated Android code (R.java)
60 check("MutablePublicArray", CheckSeverity.OFF)
Thomas Broyer2cf80112018-10-17 21:19:38 +020061 // this check is too noisy
62 check("StringSplitter", CheckSeverity.OFF)
63 check("WildcardImport", CheckSeverity.ERROR)
Manu Sridharan88bdd4a2017-08-15 14:30:41 -070064 }
65 }
66
Manu Sridharanf1a87512018-12-03 18:30:29 -080067 if (JavaVersion.current().java9Compatible) {
68 tasks.withType(JavaCompile) {
69 options.compilerArgs += [ "--release", "8" ]
70 }
71 }
72
Manu Sridharan88bdd4a2017-08-15 14:30:41 -070073 repositories {
74 jcenter()
Manu Sridharana08b2ed2017-12-11 08:58:54 -080075 google()
Manu Sridharan88bdd4a2017-08-15 14:30:41 -070076 }
77
78}
79
Manu Sridharanb4daf462017-09-26 14:03:26 -070080googleJavaFormat {
Manu Sridharan4c188132018-08-21 21:15:57 -070081 toolVersion = "1.6"
Manu Sridharanb4daf462017-09-26 14:03:26 -070082}
Lázaro Clapp8f06f382019-04-05 12:48:54 -040083
84////////////////////////////////////////////////////////////////////////
85//
86// Google Java Format pre-commit hook installation
87//
88
89tasks.register('installGitHooks', Copy) {
90 from(file('config/hooks/pre-commit-stub')) {
91 rename 'pre-commit-stub', 'pre-commit'
92 }
93 into file('.git/hooks')
94 fileMode 0777
95}