forked from square/leakcanary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
180 lines (165 loc) · 6.09 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
apply plugin: 'com.github.ben-manes.versions'
buildscript {
ext.versions = [
'minSdk': 14,
'compileSdk': 29,
'errorProne': '2.3.1',
// We would like to use Kotlin 1.4 language features but keep Kotlin 1.3 library APIs
// The benefit is that depending clients do not have to upgrade to Kotlin 1.4
'kotlinCompiler': '1.4.21',
'kotlinLib': '1.3.72',
]
ext.deps = [
assertj_core: 'org.assertj:assertj-core:3.9.1',
// We don't need the latest version of AndroidX (there are no bugs that impact what LeakCanary
// relies on), we're sticking a bit older because most apps will be using a more recent version
// and they'll automatically resolve to higher version without having to necessarily resort to a
// resolution strategy.
androidGradlePlugin: "com.android.tools.build:gradle:4.0.0",
androidx: [
annotation: 'androidx.annotation:annotation:1.0.2',
core: 'androidx.core:core:1.0.1',
fragment: 'androidx.fragment:fragment:1.0.0',
test: [
core: 'androidx.test:core:1.0.0',
espresso: 'androidx.test.espresso:espresso-core:3.1.0',
rules: 'androidx.test:rules:1.1.0',
runner: 'androidx.test:runner:1.1.0',
orchestrator: 'androidx.test:orchestrator:1.1.0',
],
],
android_support: 'com.android.support:support-v4:28.0.0',
clikt: 'com.github.ajalt:clikt:2.3.0',
curtains: 'com.squareup.curtains:curtains:1.0.1',
jline: 'jline:jline:2.14.6',
detekt: 'io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.6.0',
junit: 'junit:junit:4.12',
kotlin: [
binaryCompatibilityValidatorPlugin: "org.jetbrains.kotlinx:binary-compatibility-validator:0.2.3",
gradlePlugin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlinCompiler}",
stdlib: "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlinLib}",
reflect: "org.jetbrains.kotlin:kotlin-reflect:${versions.kotlinLib}"
],
kotlin_statistics: 'org.nield:kotlin-statistics:1.2.1',
mockito: 'org.mockito:mockito-core:3.5.10',
mockito_kotlin: 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0',
okio: 'com.squareup.okio:okio:2.2.2',
okio_1x: 'com.squareup.okio:okio:1.14.0',
robolectric: 'org.robolectric:robolectric:4.0-alpha-3',
]
repositories {
google()
gradlePluginPortal()
// For binary compatibility validator.
maven { url "https://kotlin.bintray.com/kotlinx" }
}
dependencies {
classpath deps.kotlin.gradlePlugin
classpath deps.androidGradlePlugin
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.16'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.18"
classpath deps.detekt
classpath deps.kotlin.binaryCompatibilityValidatorPlugin
}
}
// We use JetBrain's Kotlin Binary Compatibility Validator to track changes to our public binary
// APIs.
// When making a change that results in a public ABI change, the apiCheck task will fail. When this
// happens, run ./gradlew apiDump to generate updated *.api files, and add those to your commit.
// See https://github.com/Kotlin/binary-compatibility-validator
apply plugin: 'binary-compatibility-validator'
apiValidation {
// Ignore all sample projects, since they're not part of our API.
ignoredProjects += ["leakcanary-android-sample"]
}
subprojects {
group = GROUP
version = VERSION_NAME
repositories {
google()
// maven {
// url 'https://oss.sonatype.org/content/repositories/snapshots/'
// }
// mavenLocal()
jcenter()
}
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'io.gitlab.arturbosch.detekt'
dokka {
reportUndocumented = false
// BuildConfig files
packageOptions {
prefix = "com.squareup.leakcanary"
suppress = true
}
packageOptions {
prefix = "shark.internal"
suppress = true
}
packageOptions {
prefix = "leakcanary.internal"
suppress = true
}
outputFormat = 'gfm'
outputDirectory = "$rootDir/docs/api"
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += [
'-Xlint:all',
'-Xlint:-serial',
'-Xlint:-deprecation',
// espresso-core classes say they're compiled with 51.0 but contain 52.0 attributes.
// warning: [classfile] MethodParameters attribute introduced in version 52.0 class files is ignored in version 51.0 class files
// '-Werror'
]
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
// Avoid warnings of using older stdlib version 1.3 than compiler version 1.4
apiVersion = "1.3"
}
}
configurations.configureEach {
resolutionStrategy {
eachDependency { details ->
// Force all the error-prone dependencies to use the same version.
if (details.requested.group == 'com.google.errorprone' &&
details.requested.name.startsWith('error_prone_')) {
details.useVersion versions.errorProne
}
}
}
}
tasks.withType(Test).configureEach {
testLogging {
exceptionFormat 'FULL'
showCauses true
showExceptions true
showStackTraces true
}
}
detekt {
config = rootProject.files('detekt-config.yml')
parallel = true
reports {
xml.enabled = false
}
}
pluginManager.withPlugin("java") {
tasks.named("check") { dependsOn("detekt") }
tasks.named("assemble") { dependsOn(rootProject.tasks.named("installGitHooks")) }
tasks.named("clean") { dependsOn(rootProject.tasks.named("installGitHooks")) }
}
dependencies {
errorprone "com.google.errorprone:error_prone_core:${versions.errorProne}"
}
}
//Copies git hooks from /hooks folder into .git; currently used to run Detekt during push
//Git hook installation
tasks.register("installGitHooks", Copy) {
from new File(rootProject.rootDir, 'hooks')
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0777 //Make files executable
}