forked from ical4j/ical4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
294 lines (252 loc) · 10.2 KB
/
Copy pathbuild.gradle
File metadata and controls
294 lines (252 loc) · 10.2 KB
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
buildscript {
// The axion-release plugin (at its latest, 1.21.1) pulls Bouncy Castle 1.81/1.82 onto the
// plugin classpath, below the 1.84 that fixes GHSA-p93r-85wp-75v3, -cj8j-37rh-8475,
// -c3fc-8qff-9hwx and -wg6q-6289-32hp. Force the patched version until axion-release ships it.
// Build-time only; not part of the published ical4j artifact.
configurations.classpath {
resolutionStrategy {
force 'org.bouncycastle:bcprov-jdk18on:1.84',
'org.bouncycastle:bcpg-jdk18on:1.84',
'org.bouncycastle:bcpkix-jdk18on:1.84',
'org.bouncycastle:bcutil-jdk18on:1.84'
}
}
}
plugins {
id 'java-library'
id 'groovy'
id 'maven-publish'
id 'jacoco'
id 'signing'
// id 'org.hidetake.ssh' version '2.11.2' // errors when using Gradle 8.* with JDK 8
id "pl.allegro.tech.build.axion-release" version "1.21.1" // errors when using Gradle 8.* with JDK 8 (https://github.com/allegro/axion-release-plugin/issues?q=is%3Aissue+is%3Aopen+%22Gradle+8%22+in%3Atitle)
id "com.palantir.revapi" version "2.0.0"
// id "net.ltgt.errorprone" version "2.0.2" apply false
id "biz.aQute.bnd.builder" version "$bndVersion"
}
repositories {
mavenLocal()
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
registerFeature('caffeineTimezoneCache') {
usingSourceSet(sourceSets.main)
}
registerFeature('filterExpressions') {
usingSourceSet(sourceSets.main)
}
registerFeature('groovyDsl') {
usingSourceSet(sourceSets.main)
}
registerFeature('schemaValidation') {
usingSourceSet(sourceSets.main)
}
}
dependencies {
// errorprone "com.google.errorprone:error_prone_core:2.3.3"
// errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
// testcontainers (test-only) pulls commons-compress 1.24.0, below the 1.26.0 that fixes
// GHSA-4g9r-vxhx-9pgx and GHSA-4265-ccf5-phj5. Constrain to the patched version. Test scope
// only; not part of the published ical4j artifact.
constraints {
testImplementation('org.apache.commons:commons-compress:1.26.0') {
because 'CVE fixes; pulled transitively by testcontainers'
}
}
api libs.slf4j, libs.commons.codec, libs.commons.lang, libs.threeten.extra
// api ("commons-validator:commons-validator:$commonsValidatorVersion") {
// exclude group: 'commons-collections', module: 'commons-collections'
// }
compileOnly libs.jspecify
// optional timezone caching..
caffeineTimezoneCacheImplementation libs.caffeine
// optional parser for filter expressions..
filterExpressionsImplementation libs.jparsec
// optional groovy DSL for calendar builder..
groovyDslImplementation libs.groovy
//groovyDslImplementation "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
// optional JSON schema validation for structured-data..
// schemaValidationImplementation "com.github.erosb:json-sKema:$jsonSkemaVersion"
// annotationProcessor "biz.aQute.bnd:biz.aQute.bndlib:$bndVersion"
testImplementation libs.log4j.core, libs.log4j.slf4j2, libs.tagsoup,
libs.groovy.xml, libs.groovy.test, libs.junit.jupiter, libs.hamcrest,
platform(libs.spock.bom), libs.spock.core,
libs.testcontainers, libs.testcontainers.spock
testRuntimeOnly libs.junit.platform
// Required by JUnit 4-style Groovy tests in src/test/groovy/ that use
// @RunWith(Parameterized) and extend GroovyTestCase. Java tests have all
// been migrated to JUnit Jupiter and no longer require vintage. The
// junit4 dependency itself is provided transitively via groovy-test.
testRuntimeOnly libs.junit.vintage
}
test {
useJUnitPlatform()
finalizedBy jacocoTestCoverageVerification, jacocoTestReport // Ensure Jacoco is run after tests have completed
// jvmArgs = [ "-Duser.timezone=UTC" ] // Some tests require default timezone to be UTC
// ZoneRulesTimezoneIndependenceTest only has signal when the JVM starts in a non-UTC zone;
// it is executed by the dedicated timezoneIndependenceTest task instead.
exclude '**/ZoneRulesTimezoneIndependenceTest*'
// Make testcontainers usable on Podman without per-developer setup.
// Testcontainers reads its config from env vars (Java system properties are
// ignored for DOCKER_HOST and ryuk.disabled), so configure it here.
def existing = System.getenv('DOCKER_HOST')
def malformed = existing && (existing.contains('$(') || existing.contains('${'))
def socket = resolvePodmanSocket()
if (!existing || malformed) {
if (socket) {
environment 'DOCKER_HOST', "unix://${socket}"
} else if (malformed) {
// Avoid passing the broken value through to the test JVM.
environment 'DOCKER_HOST', ''
}
}
// Ryuk (the testcontainers reaper) relies on Docker-specific privileged
// semantics that hang on Podman; disable it when running against Podman.
if (socket) {
environment 'TESTCONTAINERS_RYUK_DISABLED', 'true'
}
}
// Runs the timezone-independence guard with a non-UTC JVM default zone. ZoneRules derivation must
// not depend on TimeZones.getDefault(); this catches regressions that pass under UTC-default CI.
tasks.register('timezoneIndependenceTest', Test) {
description = 'Runs ZoneRules timezone-independence guards under a non-UTC default zone.'
group = 'verification'
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
useJUnitPlatform()
systemProperty 'user.timezone', 'Australia/Sydney'
filter {
includeTestsMatching 'net.fortuna.ical4j.model.ZoneRulesTimezoneIndependenceTest'
}
}
check.dependsOn 'timezoneIndependenceTest'
def resolvePodmanSocket() {
try {
def proc = ['podman', 'machine', 'inspect', '--format',
'{{.ConnectionInfo.PodmanSocket.Path}}'].execute()
proc.waitFor()
if (proc.exitValue() == 0) {
def path = proc.text.trim().readLines().find { it && file(it).exists() }
if (path) return path
}
} catch (IOException ignored) {
// podman binary not on PATH
}
def candidates = [System.getenv('XDG_RUNTIME_DIR') ? "${System.getenv('XDG_RUNTIME_DIR')}/podman/podman.sock" : null,
'/run/podman/podman.sock',
'/var/run/podman/podman.sock',
'/var/run/docker.sock']
return candidates.findResult { it && file(it).exists() ? it : null }
}
jacocoTestCoverageVerification {
dependsOn test
violationRules {
rule {
limit {
minimum = 0.7
}
failOnViolation = false
}
}
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = jacoco_htmlReport == 'true'
}
}
javadoc {
// options.addBooleanOption('-no-module-directories', true)
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
options {
links 'https://docs.oracle.com/en/java/javase/11/docs/api/'
}
}
scmVersion {
tag {
prefix = 'ical4j-'
branchPrefix = ['ical4j-1.x-maintenance' : 'jdk14_ical4j']
branchPrefix = ['ical4j-2.x-maintenance' : 'jdk7_ical4j']
}
versionCreator 'versionWithBranch'
branchVersionCreator = ['master': 'simple']
branchVersionCreator = ['ical4j-1.x-maintenance': 'simple']
branchVersionCreator = ['ical4j-2.x-maintenance': 'simple']
branchVersionCreator = ['ical4j-3.x-maintenance': 'simple']
nextVersion {
suffix = 'pre'
separator = '-'
}
}
group = 'org.mnode.ical4j'
description = '''
A Java library for reading and writing iCalendar (*.ics) files
'''
version = scmVersion.version
jar {
manifest {
attributes (
'Implementation-Title': 'iCal4j',
'Implementation-Version': version,
'Implementation-Vendor': 'Ben Fortuna'
)
}
}
revapi {
oldVersion = revApiOldVersion
}
ext {
isReleaseVersion = !version.endsWith("SNAPSHOT")
}
publishing {
publications {
ical4j(MavenPublication) {
from components.java
pom.withXml {
asNode().appendNode('name', project.name)
asNode().appendNode('description', project.description)
asNode().appendNode('url', 'http://ical4j.github.io')
def scmNode = asNode().appendNode('scm')
scmNode.appendNode('url', 'https://github.com/ical4j/ical4j')
scmNode.appendNode('connection', 'scm:git@github.com:ical4j/ical4j.git')
scmNode.appendNode('developerConnection', 'scm:git@github.com:ical4j/ical4j.git')
def licenseNode = asNode().appendNode('licenses').appendNode('license')
licenseNode.appendNode('name', 'BSD-3-Clause')
licenseNode.appendNode('url', 'https://raw.githubusercontent.com/ical4j/ical4j/master/LICENSE.txt')
licenseNode.appendNode('distribution', 'repo')
def developerNode = asNode().appendNode('developers').appendNode('developer')
developerNode.appendNode('id', 'fortuna')
developerNode.appendNode('name', 'Ben Fortuna')
}
}
}
repositories {
maven {
name = "MavenCentral"
url = !isReleaseVersion ? "https://central.sonatype.com/repository/maven-snapshots/" : "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
// maven {
// name = "GitHubPackages"
// url = uri("https://maven.pkg.github.com/ical4j/ical4j")
// credentials {
// username = System.getenv("GPR_USERNAME")
// password = System.getenv("GPR_TOKEN")
// }
// }
}
}
signing {
required { isReleaseVersion }
sign publishing.publications.ical4j
}