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