forked from stripe/stripe-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
159 lines (135 loc) · 4.82 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
buildscript {
repositories {
mavenCentral()
//Add only for SNAPSHOT versions
//maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
}
}
plugins {
id "java"
id "maven-publish"
id "signing"
id "jacoco"
id "io.freefair.lombok" version "6.3.0"
id "com.diffplug.spotless" version "6.4.0"
id "net.ltgt.errorprone" version "2.0.2"
id "com.github.kt3k.coveralls" version "2.12.0"
id "biz.aQute.bnd.builder" version "6.1.0"
id "org.ajoberstar.git-publish" version "3.0.1"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
group = GROUP
version = VERSION_NAME
tasks.withType(JavaCompile) {
JavaVersion compilerJavaVersionEnum = JavaVersion.current()
if (compilerJavaVersionEnum != JavaVersion.VERSION_17) {
throw new GradleException("JDK 17 is required to build Stripe")
}
options.release = project.targetCompatibility.majorVersion as Integer
options.compilerArgs << "-Xlint:all" << "-Xlint:-options" << "-Xlint:-processing"
options.encoding = "UTF-8"
options.errorprone {
// This check causes warnings with autogenerated Javadoc strings.
check("InvalidParam", net.ltgt.gradle.errorprone.CheckSeverity.OFF)
// Some methods in autogen'd files (defined via overrides) lack a summary. Should be trivial
// to fix by adding the missing summaries.
check("MissingSummary", net.ltgt.gradle.errorprone.CheckSeverity.OFF)
// This check is disabled because multiple nested classes may have the same name in a given
// file. E.g. in `main/java/com/stripe/param/AccountUpdateParams.java`:
// The name `Address` refers to [com.stripe.param.AccountUpdateParams.Company.Address,
// com.stripe.param.AccountUpdateParams.Individual.Address] within this file.)
// We should fix this by having autogen use the fully-qualified class to eliminate ambiguity.
check("SameNameButDifferent", net.ltgt.gradle.errorprone.CheckSeverity.OFF)
}
}
tasks.withType(Test) {
// Check if JAVA_TEST_HOME environment variable is specified
String home = System.getenv("JAVA_TEST_HOME")
if (home && !home.allWhitespace) {
test.executable = "${home}/bin/java"
}
// Github CI should always set JAVA_TEST_HOME
else if (System.getenv("GITHUB_ACTIONS"))
{
throw new GradleException("JAVA_TEST_HOME should be set when running in CI")
}
}
compileJava {
options.compilerArgs << "-Werror"
}
configurations.all {
}
repositories {
mavenCentral()
}
dependencies {
errorprone group: "com.google.errorprone", name: "error_prone_core", version: "2.10.0"
errorproneJavac group: "com.google.errorprone", name: "javac", version:"9+181-r4173-1"
implementation group: "com.google.code.gson", name: "gson", version:"2.9.0"
testImplementation group: "com.google.guava", name: "guava", version:"31.0.1-jre"
testImplementation group: "com.squareup.okhttp3", name: "mockwebserver", version: "4.9.1"
testImplementation group: "org.mockito", name: "mockito-core", version:"4.1.0"
testImplementation group: "org.junit.jupiter", name: "junit-jupiter-api", version: "5.8.2"
testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter-engine", version: "5.8.2"
testRuntimeOnly group: "org.slf4j", name: "slf4j-api", version: "1.7.32"
}
jar {
manifest {
attributes("Implementation-Title": POM_NAME,
"Implementation-Version": VERSION_NAME,
"Implementation-Vendor": VENDOR_NAME,
"Bundle-SymbolicName": POM_ARTIFACT_ID,
"Export-Package": "com.stripe.*")
archiveVersion = VERSION_NAME
}
}
lombok {
version = "1.18.22"
}
delombok {
// empty format option, otherwise the default is to use pretty formatting which overrides
// options Lombok config options and does not add generated annotations.
format = [:]
}
apply from: "deploy.gradle"
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
}
spotless {
java {
googleJavaFormat("1.7") // 1.7 is the last version that supports Java 8
removeUnusedImports()
}
}
jacocoTestReport {
reports {
xml.required = true // coveralls plugin depends on xml format report
html.required = true
}
}
coveralls {
jacocoReportPath "build/reports/jacoco/test/jacocoTestReport.xml"
}
gitPublish {
repoUri = 'https://github.com/stripe/stripe-java.git'
branch = 'gh-pages'
sign = false // disable commit signing
contents {
from(javadoc) {
into '.'
}
}
}
jacoco
{
// test code instrumentation for Java 18
toolVersion = "0.8.8"
}