-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.gradle
More file actions
201 lines (173 loc) · 6.32 KB
/
Copy pathbuild.gradle
File metadata and controls
201 lines (173 loc) · 6.32 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
// yumi-gradle-licenser is loaded via buildscript so we can constrain its
// vulnerable transitive dependencies (log4j-core, plexus-utils). The version is
// pinned directly in the classpath declaration below.
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'dev.yumi:yumi-gradle-licenser:4.0.0'
constraints {
classpath('org.apache.logging.log4j:log4j-core:2.25.4') {
because 'GHSA-445c-vh5m-36rj, GHSA-6hg6-v5c8-fphq, GHSA-3pxv-7cmr-fjr4'
}
classpath('org.codehaus.plexus:plexus-utils:4.0.3') {
because 'GHSA-6fmv-xxpf-w3cw'
}
}
}
}
plugins {
id 'java'
id 'application'
id 'jacoco'
alias(libs.plugins.graalvmNative)
alias(libs.plugins.shadow)
}
apply plugin: 'dev.yumi.gradle.licenser'
// define these in the `gradle.properties` file
ext.githubUser = project.findProperty('github.packages.user')
ext.githubToken = project.findProperty('github.packages.token')
repositories {
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/seqeralabs/tower-java-sdk")
credentials {
username = githubUser ?: System.getenv("GITHUB_USERNAME")
password = githubToken ?: System.getenv("GITHUB_TOKEN")
}
}
}
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/**')
}
application {
mainClass.set('io.seqera.tower.cli.Tower')
}
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')
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') {
archiveBaseName.set('tw')
archiveClassifier.set('')
archiveVersion.set('')
}
tasks.named('test') {
// Use junit platform for unit tests
useJUnitPlatform()
dependsOn tasks.named('checkLicenses')
// 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
}