forked from square/retrofit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
147 lines (134 loc) · 5.42 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
import net.ltgt.gradle.errorprone.CheckSeverity
import org.gradle.internal.jvm.Jvm
buildscript {
ext.versions = [
'kotlin': '1.3.50',
'okhttp': '3.14.9',
'protobuf': '3.10.0',
'jaxb': '2.3.1',
'robovm': '2.3.9',
]
ext.deps = [
'kotlinStdLib': "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}",
'kotlinCoroutines': 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2',
'okhttp': "com.squareup.okhttp3:okhttp:${versions.okhttp}",
'mockwebserver': "com.squareup.okhttp3:mockwebserver:${versions.okhttp}",
'junit': 'junit:junit:4.13',
'assertj': 'org.assertj:assertj-core:3.13.2',
'guava': 'com.google.guava:guava:28.1-jre',
'android': 'com.google.android:android:4.1.1.4',
'animalSnifferAnnotations': 'org.codehaus.mojo:animal-sniffer-annotations:1.18',
'findBugsAnnotations': 'com.google.code.findbugs:jsr305:3.0.2',
'androidxTestRunner': 'androidx.test:runner:1.1.0',
'rxjava': 'io.reactivex:rxjava:1.3.8',
'rxjava2': 'io.reactivex.rxjava2:rxjava:2.0.0',
'rxjava3': 'io.reactivex.rxjava3:rxjava:3.0.0',
'reactiveStreams': 'org.reactivestreams:reactive-streams:1.0.3',
'scalaLibrary': 'org.scala-lang:scala-library:2.13.1',
'gson': 'com.google.code.gson:gson:2.8.5',
'jacksonDatabind': 'com.fasterxml.jackson.core:jackson-databind:2.10.5.1',
'jaxbApi': "javax.xml.bind:jaxb-api:${versions.jaxb}",
'jaxbImpl': "org.glassfish.jaxb:jaxb-runtime:${versions.jaxb}",
'moshi': 'com.squareup.moshi:moshi:1.8.0',
'protobuf': "com.google.protobuf:protobuf-java:${versions.protobuf}",
'simpleXml': 'org.simpleframework:simple-xml:2.7.1',
'wireRuntime': 'com.squareup.wire:wire-runtime:2.2.0',
'jsoup': 'org.jsoup:jsoup:1.12.1',
'robovm': "com.mobidevelop.robovm:robovm-rt:${versions.robovm}",
]
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.8.1'
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.9.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.0'
classpath 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9'
classpath "com.mobidevelop.robovm:robovm-gradle-plugin:${versions.robovm}"
}
repositories {
mavenCentral()
google()
jcenter()
gradlePluginPortal()
}
}
subprojects {
repositories {
mavenCentral()
google()
jcenter()
}
tasks.withType(JavaCompile).configureEach { task ->
task.options.encoding = 'UTF-8'
task.sourceCompatibility = JavaVersion.VERSION_1_8
task.targetCompatibility = JavaVersion.VERSION_1_8
}
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
errorprone 'com.google.errorprone:error_prone_core:2.4.0'
}
tasks.withType(JavaCompile).configureEach { task ->
task.options.errorprone {
excludedPaths = '.*/build/generated/source/proto/.*'
check('MissingFail', CheckSeverity.ERROR)
check('MissingOverride', CheckSeverity.ERROR)
check('UnusedException', CheckSeverity.ERROR)
check('UnusedMethod', CheckSeverity.ERROR)
check('UnusedNestedClass', CheckSeverity.ERROR)
check('UnusedVariable', CheckSeverity.ERROR)
}
}
plugins.withId('java-library') {
// Animal Sniffer only works on JDK 11 or older currently.
if (!Jvm.current().javaVersion.isJava12Compatible()) {
project.apply plugin: 'ru.vyarus.animalsniffer'
animalsniffer {
sourceSets = [sourceSets.main] // Only check main sources, ignore test code.
}
dependencies {
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
if (project.path != ':retrofit-converters:java8' &&
project.path != ':retrofit-converters:jaxb' &&
project.path != ':retrofit-adapters:java8') {
signature 'net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature'
}
}
}
// google-java-format only works on JDK 11 or newer.
if (Jvm.current().javaVersion.isJava11Compatible()) {
project.apply plugin: 'com.github.sherter.google-java-format'
googleJavaFormat {
toolVersion = '1.8'
// By default, the GJF plugin includes all Java folders inside the project directory. This
// does not work well with nested projects, especially when you want to exclude them.
source = sourceSets*.allJava
}
afterEvaluate {
def verify = tasks.getByName('verifyGoogleJavaFormat')
tasks.getByName('check').dependsOn(verify)
def prompt = tasks.create('promptGoogleJavaFormat') {
doLast {
println()
println('To automatically format, run "./gradlew googleJavaFormat"')
println()
}
onlyIf { verify.state.failure != null }
}
verify.finalizedBy(prompt)
}
}
}
plugins.withType(com.android.build.gradle.BasePlugin).configureEach { plugin ->
plugin.extension.compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile).configureEach { task ->
task.kotlinOptions {
jvmTarget = '1.8'
}
}
}