forked from square/retrofit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
130 lines (115 loc) · 3.87 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
import net.ltgt.gradle.errorprone.CheckSeverity
import org.gradle.internal.jvm.Jvm
buildscript {
dependencies {
classpath libs.androidPlugin
classpath libs.robovmPlugin
}
repositories {
mavenCentral()
google()
jcenter()
gradlePluginPortal()
}
}
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.errorprone) apply false
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.animalsniffer) apply false
alias(libs.plugins.googleJavaFormat) apply false
}
subprojects {
repositories {
mavenCentral()
google()
jcenter()
}
tasks.withType(JavaCompile).configureEach { task ->
task.options.encoding = 'UTF-8'
}
plugins.withType(JavaBasePlugin).configureEach {
java.toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks.withType(Test).configureEach {
testLogging {
if (System.getenv("CI") == "true") {
events = ["failed", "skipped", "passed"]
}
exceptionFormat "full"
}
}
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorproneJavac libs.errorproneJavac
errorprone libs.errorproneCore
}
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-converters:jaxb3' &&
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 to JDK 15 (without wild flags).
if (Jvm.current().javaVersion.isJava11Compatible() && !Jvm.current().javaVersion.isCompatibleWith(JavaVersion.VERSION_16)) {
project.apply plugin: 'com.github.sherter.google-java-format'
googleJavaFormat {
toolVersion = '1.15.0'
// 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 ->
// Can remove this once https://issuetracker.google.com/issues/260059413 is fixed.
plugin.extension.compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
pluginManager.withPlugin("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
}