blob: 184953350ad40a4aa430236d366e859a3e7a1937 [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
18
Manu Sridharanb4daf462017-09-26 14:03:26 -070019plugins {
Manu Sridharan01194cd2018-12-02 12:49:07 -080020 id "com.github.sherter.google-java-format" version "0.8"
Zac Sweers4d7b4d02019-04-08 08:34:06 -070021 id "net.ltgt.errorprone" version "0.7" apply false
Thomas Broyer2cf80112018-10-17 21:19:38 +020022 id "com.github.johnrengelman.shadow" version "2.0.4" apply false
23 id 'com.github.kt3k.coveralls' version '2.6.3' apply false
Zac Sweers4d7b4d02019-04-08 08:34:06 -070024 id 'com.android.application' version '3.3.1' apply false
Manu Sridharanb4daf462017-09-26 14:03:26 -070025}
26
27repositories {
28 // to get the google-java-format jar and dependencies
29 jcenter()
30}
31
Thomas Broyer2cf80112018-10-17 21:19:38 +020032apply from: "gradle/dependencies.gradle"
33
Manu Sridharan4c188132018-08-21 21:15:57 -070034subprojects { project ->
Thomas Broyer2cf80112018-10-17 21:19:38 +020035 project.apply plugin: "net.ltgt.errorprone"
36 project.dependencies {
37 errorprone deps.build.errorProneCore
38 errorproneJavac deps.build.errorProneJavac
Manu Sridharan4c188132018-08-21 21:15:57 -070039 }
Thomas Broyer2cf80112018-10-17 21:19:38 +020040 project.tasks.withType(JavaCompile) {
Lázaro Clapp8f06f382019-04-05 12:48:54 -040041 dependsOn(installGitHooks)
Thomas Broyer2cf80112018-10-17 21:19:38 +020042 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 Sridharan88bdd4a2017-08-15 14:30:41 -070053 }
54 }
55
Manu Sridharanf1a87512018-12-03 18:30:29 -080056 if (JavaVersion.current().java9Compatible) {
57 tasks.withType(JavaCompile) {
58 options.compilerArgs += [ "--release", "8" ]
59 }
60 }
61
Manu Sridharan88bdd4a2017-08-15 14:30:41 -070062 repositories {
Lázaro Clapp7d6e2532017-09-28 15:15:45 -070063 maven {
Lázaro Clappe51677f2018-08-06 19:43:30 -070064 url "https://raw.githubusercontent.com/lazaroclapp/WALA/repository/"
65 }
Manu Sridharan88bdd4a2017-08-15 14:30:41 -070066 jcenter()
Manu Sridharana08b2ed2017-12-11 08:58:54 -080067 google()
Manu Sridharan88bdd4a2017-08-15 14:30:41 -070068 }
69
70}
71
Manu Sridharanb4daf462017-09-26 14:03:26 -070072googleJavaFormat {
Manu Sridharan4c188132018-08-21 21:15:57 -070073 toolVersion = "1.6"
Manu Sridharanb4daf462017-09-26 14:03:26 -070074}
Lázaro Clapp8f06f382019-04-05 12:48:54 -040075
76////////////////////////////////////////////////////////////////////////
77//
78// Google Java Format pre-commit hook installation
79//
80
81tasks.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}