Skip to content

Commit 4a3b67a

Browse files
authored
fix: make Java test gradle self-contained (#3791)
Fixes #3775 The gradle tasks call into the `xtask` command, directly from the `test` task. --------- Signed-off-by: Andrew Duffy <[email protected]>
1 parent a778204 commit 4a3b67a

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,6 @@ jobs:
345345
- uses: actions/checkout@v4
346346
- uses: ./.github/actions/cleanup
347347
- uses: ./.github/actions/setup-rust
348-
# Build vortex-jni shared library, and copy into JAR.
349-
- name: Build vortex-jni
350-
run: |
351-
cargo build -p vortex-jni
352-
mkdir -p java/vortex-jni/src/main/resources/native/linux-amd64
353-
cargo xtask java-test-files
354-
cp target/debug/libvortex_jni.so java/vortex-jni/src/main/resources/native/linux-amd64
355348
- run: ./gradlew test --parallel
356349
working-directory: ./java
357350

java/vortex-jni/build.gradle.kts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
5-
import com.vanniktech.maven.publish.SonatypeHost
5+
import org.gradle.kotlin.dsl.support.serviceOf
66

77
plugins {
88
`java-library`
@@ -41,7 +41,7 @@ testing {
4141

4242
mavenPublishing {
4343
coordinates(groupId = "dev.vortex", artifactId = "vortex-jni", version = "${rootProject.version}")
44-
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
44+
publishToMavenCentral()
4545

4646
signAllPublications()
4747

@@ -109,6 +109,49 @@ tasks.build {
109109
dependsOn("shadowJar")
110110
}
111111

112+
tasks.register("makeTestFiles") {
113+
description = "Generate files used by unit tests"
114+
group = "verification"
115+
116+
doLast {
117+
println("makeTestFiles executed")
118+
119+
val execOps = serviceOf<ExecOperations>()
120+
121+
// Build the JNI lib
122+
123+
execOps.exec {
124+
workingDir = rootProject.projectDir.absoluteFile.parentFile
125+
executable = "cargo"
126+
args("build", "--package", "vortex-jni")
127+
}
128+
129+
copy {
130+
from("${rootProject.projectDir.absoluteFile.parentFile}/target/debug/libvortex_jni.so")
131+
into("$projectDir/src/main/resources/native/linux-amd64")
132+
}
133+
134+
copy {
135+
from("${rootProject.projectDir.absoluteFile.parentFile}/target/debug/libvortex_jni.dylib")
136+
into("$projectDir/src/main/resources/native/darwin-aarch64")
137+
}
138+
139+
execOps.exec {
140+
workingDir = rootProject.projectDir.absoluteFile.parentFile
141+
executable = "cargo"
142+
args("xtask", "java-test-files")
143+
}
144+
}
145+
}
146+
147+
tasks.named("processResources").configure {
148+
dependsOn("makeTestFiles")
149+
}
150+
151+
tasks.withType<Test>().all {
152+
dependsOn("makeTestFiles")
153+
}
154+
112155
tasks.register("generateJniHeaders") {
113156
description = "Generates JNI header files for Java classes with native methods"
114157
group = "build"

java/vortex-spark/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
import com.vanniktech.maven.publish.SonatypeHost
5-
64
apply(plugin = "com.vanniktech.maven.publish")
75

86
plugins {
@@ -32,7 +30,7 @@ testing {
3230
mavenPublishing {
3331
coordinates(groupId = "dev.vortex", artifactId = "vortex-spark", version = "${rootProject.version}")
3432

35-
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
33+
publishToMavenCentral()
3634

3735
signAllPublications()
3836

0 commit comments

Comments
 (0)