Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
186 lines (160 loc) · 6.16 KB
/
Copy pathbuild.gradle
File metadata and controls
186 lines (160 loc) · 6.16 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
plugins {
id 'java'
id 'application'
id 'jacoco'
alias(libs.plugins.graalvmNative)
alias(libs.plugins.shadow)
alias(libs.plugins.yumiLicenser)
}
repositories {
mavenCentral()
maven { url = 'https://s3-eu-west-1.amazonaws.com/maven.seqera.io/releases' }
}
dependencies {
// Align all Jackson modules to a non-vulnerable version (GHSA-72hv-8253-57qq)
implementation(platform(libs.jacksonBom))
testImplementation(platform(libs.jacksonBom))
implementation(libs.javaxAnnotation)
implementation(libs.jakartaAnnotation)
implementation(libs.slf4jApi)
implementation(libs.logbackCore)
implementation(libs.logbackClassic)
implementation(libs.towerJavaSdk)
// Upgrade transitive Jersey client dependencies to non-vulnerable 2.x version
implementation(libs.jerseyClient)
implementation(libs.jerseyMediaMultipart)
implementation(libs.jerseyMediaJsonJackson)
implementation(libs.jerseyHk2)
implementation(libs.picocli)
implementation(libs.commonsCompress)
implementation(libs.xz)
implementation(libs.classgraph)
annotationProcessor(libs.picocliCodegen)
testImplementation(libs.mockserverClientJava)
testImplementation(libs.mockserverNetty)
testImplementation(libs.mockserverJunitJupiter)
// Upgrade transitive mock-server dependencies to non-vulnerable 2.x version
testImplementation(libs.commonsIo)
testImplementation(libs.junitJupiterApi)
testImplementation(libs.junitJupiterParams)
testRuntimeOnly(libs.junitJupiterEngine)
testRuntimeOnly(libs.junitPlatformLauncher)
}
license {
rule(file('HEADER.txt'))
exclude('**/*.properties')
exclude('**/*.xml')
exclude('**/*.json')
exclude('**/*.csv')
exclude('**/*.txt')
exclude('**/*.sh')
exclude('gradlew')
exclude('conf/**')
}
// Jersey's HttpURLConnection connector can only send PATCH by reflecting into these JDK internals
// (HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, enabled by the SDK's ApiClient)
def jerseyPatchOpens = ['java.base/java.net', 'java.base/sun.net.www.protocol.https']
application {
mainClass.set('io.seqera.tower.cli.Tower')
applicationDefaultJvmArgs = jerseyPatchOpens.collect { "--add-opens=${it}=ALL-UNNAMED" }
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
graalvmNative {
toolchainDetection = true
binaries {
main {
imageName = 'tw'
mainClass = 'io.seqera.tower.cli.Tower'
configurationFileDirectories.from(file('conf'))
if (System.env.getOrDefault("PLATFORM", "") == "linux-x86_64") {
buildArgs(['--static', '--libc=musl', '--gc=G1', '-march=compatibility'])
}
buildArgs.add('--allow-incomplete-classpath')
buildArgs.add('--report-unsupported-elements-at-runtime')
buildArgs.add('-H:+AddAllCharsets')
buildArgs.add('-H:EnableURLProtocols=https,http')
buildArgs.add('-H:+ReportExceptionStackTraces')
// Native images enforce module encapsulation for setAccessible too, so the reflection entries alone are not enough
buildArgs.addAll(jerseyPatchOpens.collect { "--add-opens=${it}=ALL-UNNAMED" })
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(25)
vendor = JvmVendorSpec.matching("Oracle Corporation")
}
}
test {
verbose = true
}
}
}
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
tasks.register('buildInfo') {
doLast {
def version = rootProject.file('VERSION').text.trim()
def versionApi = rootProject.file('VERSION-API').readLines().get(0).trim()
def commitId = System.env.getOrDefault("GITHUB_SHA", "unknown").substring(0, 7)
def platform = System.env.getOrDefault("PLATFORM", "java")
def info = """\
version=${version}
versionApi=${versionApi}
commitId=${commitId}
platform=${platform}
""".stripIndent().toString()
def f = file("src/main/resources/META-INF/build-info.properties")
f.parentFile.mkdirs()
f.text = info
}
}
tasks.named('compileJava') {
options.release = 25
options.compilerArgs += ["-Aproject=${project.name}"]
dependsOn tasks.named('buildInfo')
}
tasks.named('run') {
// Pass CLI arguments via: `./gradlew run --args='arg1 arg2'`, or via: `./gradlew run -Pargs='arg1 arg2'`
if (project.hasProperty('args')) {
args project.args.split('\\s+')
}
// Run with GraalVM Tracing Agent enabled
if (System.getProperty('tracing-agent')?.toBoolean()) {
jvmArgs += ["-agentlib:native-image-agent=access-filter-file=conf/access-filter-file.json,config-merge-dir=conf/"]
}
}
tasks.register('runReflectionConfigGenerator', JavaExec) {
group = 'build'
description = 'Run ReflectionConfigGenerator for Tower SDK with native-image-agent'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'io.seqera.tower.cli.utils.config.ReflectionConfigGenerator'
jvmArgs = ["-agentlib:native-image-agent=access-filter-file=conf/access-filter-file.json,config-merge-dir=conf/"]
}
tasks.named('shadowJar') {
manifest {
attributes 'Add-Opens': jerseyPatchOpens.join(' ')
}
archiveBaseName.set('tw')
archiveClassifier.set('')
archiveVersion.set('')
}
tasks.named('test') {
// Use junit platform for unit tests
useJUnitPlatform()
dependsOn tasks.named('checkLicenses')
// Log the full stack trace (and the assertion message) of failing tests
testLogging {
events 'failed'
exceptionFormat = 'full'
}
jvmArgs jerseyPatchOpens.collect { "--add-opens=${it}=ALL-UNNAMED" }
// Run tests with GraalVM Tracing Agent enabled
if (System.getProperty('tracing-agent')?.toBoolean()) {
jvmArgs += ["-agentlib:native-image-agent=access-filter-file=conf/access-filter-file.json,config-merge-dir=conf/"]
}
}
tasks.named('jacocoTestReport') {
dependsOn tasks.named('test') // tests are required to run before generating the report
}