Manu Sridharan | 88bdd4a | 2017-08-15 14:30:41 -0700 | [diff] [blame] | 1 | /* |
| 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 Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 17 | import net.ltgt.gradle.errorprone.CheckSeverity |
Manu Sridharan | e43fc1e | 2020-02-13 12:34:00 -0800 | [diff] [blame] | 18 | buildscript { |
| 19 | repositories { |
| 20 | google() // For Gradle 4.0+ |
| 21 | } |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 22 | |
Manu Sridharan | e43fc1e | 2020-02-13 12:34:00 -0800 | [diff] [blame] | 23 | dependencies { |
| 24 | classpath 'com.android.tools.build:gradle:3.5.0' |
| 25 | } |
| 26 | } |
Manu Sridharan | b4daf46 | 2017-09-26 14:03:26 -0700 | [diff] [blame] | 27 | plugins { |
Manu Sridharan | 01194cd | 2018-12-02 12:49:07 -0800 | [diff] [blame] | 28 | id "com.github.sherter.google-java-format" version "0.8" |
Zac Sweers | 4d7b4d0 | 2019-04-08 08:34:06 -0700 | [diff] [blame] | 29 | id "net.ltgt.errorprone" version "0.7" apply false |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 30 | id "com.github.johnrengelman.shadow" version "2.0.4" apply false |
Lázaro Clapp | eed3fc0 | 2021-01-05 14:27:41 -0500 | [diff] [blame^] | 31 | id "com.github.nbaztec.coveralls-jacoco" version "1.2.5" apply false |
| 32 | id "com.android.application" version "3.5.0" apply false |
Manu Sridharan | b4daf46 | 2017-09-26 14:03:26 -0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | repositories { |
| 36 | // to get the google-java-format jar and dependencies |
| 37 | jcenter() |
| 38 | } |
| 39 | |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 40 | apply from: "gradle/dependencies.gradle" |
| 41 | |
Manu Sridharan | 4c18813 | 2018-08-21 21:15:57 -0700 | [diff] [blame] | 42 | subprojects { project -> |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 43 | project.apply plugin: "net.ltgt.errorprone" |
| 44 | project.dependencies { |
| 45 | errorprone deps.build.errorProneCore |
| 46 | errorproneJavac deps.build.errorProneJavac |
Manu Sridharan | 4c18813 | 2018-08-21 21:15:57 -0700 | [diff] [blame] | 47 | } |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 48 | project.tasks.withType(JavaCompile) { |
Lázaro Clapp | 8f06f38 | 2019-04-05 12:48:54 -0400 | [diff] [blame] | 49 | dependsOn(installGitHooks) |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 50 | options.compilerArgs += [ |
Lázaro Clapp | bf3de0f | 2020-06-24 12:38:46 -0400 | [diff] [blame] | 51 | "-Xlint:deprecation", |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 52 | "-Xlint:rawtypes", |
Lázaro Clapp | bf3de0f | 2020-06-24 12:38:46 -0400 | [diff] [blame] | 53 | "-Xlint:unchecked", |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 54 | "-Werror" |
| 55 | ] |
| 56 | options.errorprone { |
| 57 | // disable warnings in generated code; AutoValue code fails UnnecessaryParentheses check |
| 58 | disableWarningsInGeneratedCode = true |
Lázaro Clapp | bf3de0f | 2020-06-24 12:38:46 -0400 | [diff] [blame] | 59 | // Triggers for generated Android code (R.java) |
| 60 | check("MutablePublicArray", CheckSeverity.OFF) |
Thomas Broyer | 2cf8011 | 2018-10-17 21:19:38 +0200 | [diff] [blame] | 61 | // this check is too noisy |
| 62 | check("StringSplitter", CheckSeverity.OFF) |
| 63 | check("WildcardImport", CheckSeverity.ERROR) |
Manu Sridharan | 88bdd4a | 2017-08-15 14:30:41 -0700 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | |
Manu Sridharan | f1a8751 | 2018-12-03 18:30:29 -0800 | [diff] [blame] | 67 | if (JavaVersion.current().java9Compatible) { |
| 68 | tasks.withType(JavaCompile) { |
| 69 | options.compilerArgs += [ "--release", "8" ] |
| 70 | } |
| 71 | } |
| 72 | |
Manu Sridharan | 88bdd4a | 2017-08-15 14:30:41 -0700 | [diff] [blame] | 73 | repositories { |
| 74 | jcenter() |
Manu Sridharan | a08b2ed | 2017-12-11 08:58:54 -0800 | [diff] [blame] | 75 | google() |
Manu Sridharan | 88bdd4a | 2017-08-15 14:30:41 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | } |
| 79 | |
Manu Sridharan | b4daf46 | 2017-09-26 14:03:26 -0700 | [diff] [blame] | 80 | googleJavaFormat { |
Manu Sridharan | 4c18813 | 2018-08-21 21:15:57 -0700 | [diff] [blame] | 81 | toolVersion = "1.6" |
Manu Sridharan | b4daf46 | 2017-09-26 14:03:26 -0700 | [diff] [blame] | 82 | } |
Lázaro Clapp | 8f06f38 | 2019-04-05 12:48:54 -0400 | [diff] [blame] | 83 | |
| 84 | //////////////////////////////////////////////////////////////////////// |
| 85 | // |
| 86 | // Google Java Format pre-commit hook installation |
| 87 | // |
| 88 | |
| 89 | tasks.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 | } |