-
Notifications
You must be signed in to change notification settings - Fork 111
/
build.gradle
331 lines (293 loc) · 9.07 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath 'ru.vyarus:gradle-quality-plugin:4.7.0'
classpath 'pl.allegro.tech.build:axion-release-plugin:1.14.2'
classpath 'io.github.gradle-nexus:publish-plugin:2.0.0'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.13.0' // above this version requires Java 11
}
}
apply plugin: 'pl.allegro.tech.build.axion-release'
apply plugin: 'java-library-distribution'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'jacoco'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'ru.vyarus.quality'
apply plugin: 'io.github.gradle-nexus.publish-plugin'
archivesBaseName = 'pw-swift-core'
group 'com.prowidesoftware'
project.ext {
SRU = 'SRU2023'
}
scmVersion {
tag {
prefix.set("${SRU}")
versionSeparator.set('-')
}
}
project.version = "${SRU}-${scmVersion.version}"
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
doFirst {
println 'Compiling with ' + getJavaCompiler().get().getMetadata().getInstallationPath()
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.code.gson:gson:2.9.0'
compileOnly 'javax.persistence:javax.persistence-api:2.2'
compileOnly 'javax.xml.bind:jaxb-api:2.3.1'
compileOnly 'javax.validation:validation-api:2.0.1.Final'
testImplementation 'javax.persistence:javax.persistence-api:2.2'
testImplementation('org.junit.jupiter:junit-jupiter:5.8.2')
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.22.0'
testImplementation group: 'org.xmlunit', name: 'xmlunit-core', version: '2.9.0'
testImplementation group: 'org.xmlunit', name: 'xmlunit-matchers', version: '2.9.0'
testImplementation group: 'org.xmlunit', name: 'xmlunit-assertj', version: '2.9.0'
}
sourceSets.main.java.srcDirs = ['src/main/java', 'src/generated/java']
test {
useJUnitPlatform()
}
tasks.withType(Jar) {
manifest.attributes(
'Specification-Title': 'Prowide Core',
'Specification-Version': project.version,
'Specification-Vendor': "${SRU}",
'Implementation-Title': 'Prowide Core',
'Implementation-Version': project.version,
'Implementation-Vendor': 'www.prowidesoftware.com',
'Built-OS': System.getProperty('os.name'),
'Source-Compatibility': project.sourceCompatibility,
'Target-Compatibility': project.targetCompatibility,
'Built-Date': new Date().format("yyyy-MM-dd"),
'Automatic-Module-Name': 'com.prowidesoftware.core'
)
}
tasks.register('sourcesJar', Jar) {
dependsOn classes
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
def formattedDate() {
new Date().format('dd MMM yyyy')
}
javadoc {
failOnError true
options.overview = "overview.html"
options.header = "${version}"
options.windowTitle = "Prowide Core API Reference"
options.footer="${SRU}, generated ${formattedDate()}"
// this will fail when the option is not available (older JDK)
options.addBooleanOption("-allow-script-in-comments", true)
options.bottom = '<script src="//static.getclicky.com/js"></script><script>try{ clicky.init(101039278); }catch(e){}</script>'
exclude "**/internal/**"
options.addStringOption('Xdoclint:none', '-quiet')
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar, sourcesJar
}
project.ext {
nexusRepo = project.version.endsWith('-SNAPSHOT') ? 'maven-snapshots' : 'maven-releases'
}
publishing {
publications {
mavenJava(MavenPublication) {
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
afterEvaluate {
from components.java
artifactId = 'pw-swift-core'
groupId = 'com.prowidesoftware'
version = "${version}"
pom {
name = 'Prowide Core'
description = 'Prowide Library for SWIFT messages'
url = 'http://www.prowidesoftware.com'
scm {
url = 'https://github.com/prowide/prowide-core.git'
connection = '[email protected]:prowide/prowide-core.git'
}
inceptionYear = '2006'
licenses {
license {
name = 'Apache License Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0'
distribution = 'repo'
}
}
developers {
developer {
id = 'zubri'
name = 'Sebastian Zubrinic'
email = '[email protected]'
}
}
organization {
name = 'Prowide'
url = 'http://www.prowidesoftware.com'
}
}
}
}
}
// Prowide repo releases
if (project.hasProperty('prowideRepo')) {
repositories {
maven {
url "${project.prowideRepo}/repository/${nexusRepo}/"
credentials {
username "${project.prowideRepoUser}"
password "${project.prowideRepoPass}"
}
}
}
} else {
project.logger.info('Prowide publishing disabled because repository properties are undefined')
}
}
jar.finalizedBy generatePomFileForMavenJavaPublication
tasks.withType(GenerateModuleMetadata) {
// to avoid metadata in the generated pom.xml files
enabled = false
}
// OSS Sonatype releases
signing {
required { project.hasProperty('SONATYPE_RELEASE') }
sign publishing.publications.mavenJava
}
java {
withJavadocJar()
withSourcesJar()
}
nexusPublishing {
repositories {
sonatype()
}
}
// Zip GitHub releases
distributions {
main {
contents {
from javadocJar
from sourcesJar
into ('lib') {
from (project.configurations.runtimeClasspath)
}
from files('LICENSE.txt')
from files('CHANGELOG.md')
from ("$buildDir/publications/mavenJava/pom-default.xml") {
rename ".*", "pom.xml"
}
}
}
}
distTar.enabled = false
distZip {
dependsOn generatePomFileForMavenJavaPublication
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Alternative (manual) staging upload to OSS Sonatype
tasks.register('bundle', Jar) {
dependsOn build
onlyIf {
project.hasProperty('SONATYPE_RELEASE')
}
description 'Creates the bundle.jar for Maven Central distribution'
from jar
from sourcesJar
from javadocJar
from ("$buildDir/publications/mavenJava/pom-default.xml") {
rename ".*", "pom.xml"
}
from ("$buildDir/publications/mavenJava/pom-default.xml.asc") {
rename ".*", "pom.xml.asc"
}
from ("$buildDir/libs") {
include '*.asc'
}
archiveName 'bundle.jar'
}
tasks.withType(Test) {
doFirst {
println 'Running test on ' + getJavaLauncher().get().getMetadata().getInstallationPath()
}
}
task('testOn11', type: Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
}
task('testOn17', type: Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
}
// exclude generated code
afterEvaluate {
getClassDirectories().setFrom(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/SchemeConstants**',
'**/mt0xx/**',
'**/mt1xx/**',
'**/mt2xx/**',
'**/mt3xx/**',
'**/mt4xx/**',
'**/mt5xx/**',
'**/mt6xx/**',
'**/mt7xx/**',
'**/mt8xx/**',
'**/mt9xx/**'
])
})
}
}
test.finalizedBy jacocoTestReport
quality {
strict = false
// we limit this to spotbugs for the moment
checkstyle = false
codenarc = false
cpd = false
pmd = false
spotbugsEffort = 'min'
spotbugsMaxRank = 8
}
apply plugin: 'com.diffplug.spotless'
spotless {
java {
target '**/src/main/java/**/*.java', '**/src/test/java/**/*.java'
palantirJavaFormat()
}
}
test.finalizedBy(spotlessCheck)