-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.common.gradle
221 lines (195 loc) · 6.16 KB
/
build.common.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
212
213
214
215
216
217
218
219
220
221
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
ext.artifactoryUser = project.hasProperty("artifactoryUser") ? project.artifactoryUser : System.env.ARTIFACTORY_USER as String
ext.artifactoryPassword = project.hasProperty("artifactoryPassword") ? project.artifactoryPassword : System.env.ARTIFACTORY_PASSWORD as String
ext.projectGitHubRepoName = "tw-context"
ext.projectScmUrl = "https://github.com/transferwise/${projectGitHubRepoName}"
ext.projectScmConnection = "scm:git:git://github.com/transferwise/${projectGitHubRepoName}.git"
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
}
apply plugin: "java-library"
apply plugin: "maven-publish"
apply plugin: "checkstyle"
apply plugin: "idea"
apply plugin: "com.github.spotbugs"
apply plugin: "signing"
apply from: "../build.libraries.gradle"
group = "com.transferwise.common"
repositories {
mavenCentral()
mavenLocal()
}
configurations {
local {
canBeResolved(false)
canBeConsumed(false)
}
compileClasspath {
extendsFrom(local)
}
runtimeClasspath {
extendsFrom(local)
}
testCompileClasspath {
extendsFrom(local)
}
testRuntimeClasspath {
extendsFrom(local)
}
annotationProcessor {
extendsFrom(local)
}
testAnnotationProcessor {
extendsFrom(local)
}
}
dependencies {
local(platform(libraries.springBootDependencies))
annotationProcessor(libraries.lombok)
annotationProcessor(libraries.springBootConfigurationProcessor)
compileOnly(libraries.lombok)
compileOnly(libraries.springBootConfigurationProcessor)
compileOnly libraries.spotbugsAnnotations
testAnnotationProcessor(libraries.lombok)
testImplementation(libraries.lombok)
testImplementation(libraries.logbackClassic)
testImplementation(libraries.junitJupiter)
testImplementation(libraries.assertjCore)
}
java {
if (springBootVersion.startsWith("3.")) {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
else{
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
withSourcesJar()
withJavadocJar()
}
jar {
manifest {
attributes(
"Implementation-Title": "Transferwise Base Utils",
"Implementation-Version": archiveVersion
)
}
}
compileJava {
options.encoding = 'utf-8'
options.compilerArgs << '-parameters'
options.compilerArgs << '-Xlint'
options.compilerArgs << '-Xlint:-processing'
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
afterEvaluate {
artifactId = projectArtifactName
}
/*
This ensures that libraries will have explicit dependency versions in their Maven POM and Gradle module files, so that there would be less
ambiguity and less chances of dependency conflicts.
*/
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionOf('runtimeClasspath')
}
}
pom {
name = projectName
description = projectDescription
url = projectScmUrl
packaging = "jar"
licenses {
license {
name = 'The Apache License, Version 2.0, Copyright 2021 TransferWise Ltd'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'onukristo'
name = 'Kristo Kuusküll'
email = "kristo.kuuskull@transferwise.com"
organization = "Transferwise Ltd"
organizationUrl = "https://github.com/transferwise"
}
}
scm {
connection = projectScmConnection
developerConnection = projectScmConnection
url = projectScmUrl
}
withXml {
if (!asNode().dependencyManagement.isEmpty()){
throw new IllegalStateException("There should not be any `dependencyManagement` block in POM.")
}
}
}
}
}
if (System.getenv("OSS_SIGNING_KEY")) {
signing {
useInMemoryPgpKeys(System.getenv("OSS_SIGNING_KEY"), System.getenv("OSS_SIGNING_PASSWORD"))
sign publishing.publications.mavenJava
}
}
repositories {
maven {
url System.getenv("MAVEN_URL")
credentials {
username = System.getenv("MAVEN_USER")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
test {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
useJUnitPlatform()
testLogging {
events TestLogEvent.STARTED, TestLogEvent.FAILED, TestLogEvent.SKIPPED, TestLogEvent.PASSED,
TestLogEvent.STANDARD_ERROR
showExceptions = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
}
tasks.findAll { it.name.startsWith("spotbugs") }*.configure {
effort = "max"
excludeFilter = file('../spotbugs-exclude.xml')
reports {
xml.required = true
html.required = true
}
}
spotbugs {
spotbugsTest.enabled = false
}
tasks.withType(Checkstyle) {
config = resources.text.fromFile(file('../google_checks.xml'))
maxWarnings = 0
reports {
xml.required = true
html.required = true
}
}