-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
211 lines (185 loc) · 6.41 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
plugins {
id 'java-library'
// to unleash the lombok magic
id "io.freefair.lombok" version "8.10.2"
// to make our tests output more fancy
id 'com.adarshr.test-logger' version '4.0.0'
// to publish packages
id 'maven-publish'
// code linting
id "com.diffplug.spotless" version "6.25.0"
// test coverage
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.12.2'
// signing
id "signing"
// nexus publishing
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
spotless {
java {
palantirJavaFormat()
}
}
task createProperties(dependsOn: processResources) {
doLast {
file("${layout.buildDirectory.get()}/resources/main/truelayer-java.version.properties").withWriter { w ->
Properties p = new Properties()
p['name'] = archivesBaseName
p['version'] = project.version != "unspecified" ? project.version : "DEVELOPMENT"
p.store w, null
}
}
}
classes {
dependsOn createProperties
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
test {
useJUnitPlatform{
excludeTags "acceptance" // exclude acceptance tests from the default test task
}
}
testlogger {
theme 'mocha'
}
tasks.register('unit-tests', Test) {
outputs.upToDateWhen { false }
useJUnitPlatform{
excludeTags "integration"
excludeTags "acceptance"
}
}
tasks.register('integration-tests', Test) {
outputs.upToDateWhen { false }
useJUnitPlatform{
includeTags "integration"
}
}
tasks.register('acceptance-tests', Test) {
outputs.upToDateWhen { false }
useJUnitPlatform{
includeTags "acceptance"
}
// toggle this to see raw logs during acceptance tests
testLogging.showStandardStreams = false
}
dependencies {
// Utilities
implementation group: 'org.apache.commons', name: 'commons-configuration2', version: '2.11.0'
// HTTP client
def retrofitVersion = '2.9.0'
implementation group: 'com.squareup.retrofit2', name: 'retrofit', version: retrofitVersion
implementation group: 'com.squareup.retrofit2', name: 'converter-jackson', version: retrofitVersion
// TL signing library
implementation group: 'com.truelayer', name: 'truelayer-signing', version: '0.2.6'
// Serialization
def jacksonVersion = '2.14.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jacksonVersion
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: jacksonVersion
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: jacksonVersion
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
// Logging
def tinyLogVersion = '2.5.0'
implementation group: 'org.tinylog', name: 'tinylog-api', version: tinyLogVersion
implementation group: 'org.tinylog', name: 'tinylog-impl', version: tinyLogVersion
// JUnit test framework.
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.11.3'
// Mocking libraries
testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.14.2'
testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.9.2'
// Wait test utility
testImplementation group: 'org.awaitility', name: 'awaitility', version: '4.2.2'
// Transitive dependencies constraints
constraints {
implementation('com.squareup.okhttp3:okhttp:4.12.0') {
because 'version 3.14.9 used by com.squareup.retrofit2:retrofit:2.9.0 has known vulnerabilities'
}
}
}
jacocoTestReport {
dependsOn "unit-tests"
reports {
xml.required = true
html.required = true
}
getExecutionData().setFrom(fileTree(buildDir).include("/jacoco/unit-tests.exec"))
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'com/truelayer/java/**/entities/**',
'com/truelayer/java/common/Constants.*',
'com/truelayer/java/common/Constants$*.*',
'com/truelayer/java/http/TrueLayerApiAdapterFactory.*',
'com/truelayer/java/http/TrueLayerResponseCallAdapter.*',
'com/truelayer/java/http/TrueLayerResponseCallAdapter$*.*'
])
}))
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
artifact sourcesJar
artifact javadocJar
pom {
name = project_name
packaging = 'jar'
description = project_description
url = project_url
scm {
connection = project_scm
developerConnection = project_scm
url = project_url
}
licenses {
license {
name = project_license_name
url = project_license_url
}
}
developers {
developer {
id = project_developer
name = project_developer
}
}
}
}
}
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
signing {
def signingKey = System.getenv('SONATYPE_GPG_KEY')
def signingPassword = System.getenv('SONATYPE_GPG_PASSPHRASE')
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
}
nexusPublishing {
repositories {
sonatype {
nexusUrl = uri(sonatype_repository_url)
snapshotRepositoryUrl = uri(sonatype_snapshot_repository_url)
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}