Skip to content

Commit cddd19a

Browse files
authored
feat: update to java 23 (#7)
1 parent 7789c36 commit cddd19a

15 files changed

Lines changed: 283 additions & 301 deletions

File tree

build.gradle.kts

Lines changed: 127 additions & 255 deletions
Large diffs are not rendered by default.

buildSrc/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
gradlePluginPortal()
8+
}

buildSrc/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "buildSrc"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import org.gradle.api.file.DirectoryProperty
2+
import org.gradle.api.file.RegularFileProperty
3+
import org.gradle.api.provider.ListProperty
4+
import org.gradle.api.provider.Property
5+
import org.gradle.api.tasks.*
6+
import org.gradle.jvm.toolchain.JavaLanguageVersion
7+
import org.gradle.jvm.toolchain.JavaToolchainService
8+
import org.gradle.jvm.toolchain.JvmVendorSpec
9+
import javax.inject.Inject
10+
11+
@CacheableTask
12+
abstract class JExtractTask @Inject constructor(
13+
private val javaToolchains: JavaToolchainService
14+
) : Exec() {
15+
16+
@get:InputFile
17+
@PathSensitive(value = PathSensitivity.RELATIVE)
18+
val header: RegularFileProperty = project.objects.fileProperty()
19+
20+
@get:Input
21+
val targetPackage: Property<String> = project.objects.property(String::class.java)
22+
23+
@get:Input
24+
val extraArgs: ListProperty<String> = project.objects.listProperty(String::class.java)
25+
26+
@get:OutputDirectory
27+
val outputDir: DirectoryProperty = project.objects.directoryProperty().convention(project.provider {
28+
val pkg = targetPackage.get().replace(".", "/")
29+
project.layout.projectDirectory.dir("src/generated/java/$pkg")
30+
})
31+
32+
@TaskAction
33+
override fun exec() {
34+
val launcher = javaToolchains.launcherFor {
35+
languageVersion.set(JavaLanguageVersion.of(23))
36+
vendor.set(JvmVendorSpec.ADOPTIUM)
37+
}.get()
38+
39+
val jdkHome = launcher.metadata.installationPath.asFile
40+
val jextract = jdkHome.resolve("bin/jextract")
41+
if (!jextract.exists()) {
42+
throw IllegalStateException("jextract not found at ${jextract.absolutePath}")
43+
}
44+
45+
commandLine(
46+
listOf(
47+
jextract,
48+
header.get(), "--output", "src/generated/java",
49+
"--target-package", targetPackage.get()
50+
) + extraArgs.get()
51+
)
52+
workingDir = this.project.layout.projectDirectory.asFile
53+
super.exec()
54+
}
55+
}

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Gradle config
2+
# Have to disable configuration cache because out native build doesnt support it.
3+
org.gradle.configuration-cache=false
4+
org.gradle.parallel=true
5+
org.gradle.caching=true
6+
org.gradle.configureondemand=true

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
metadata.format.version = "1.1"
22

33
[versions]
4-
annotations = "24.1.0"
4+
annotations = "26.0.2"
55

66
nexuspublish = "1.3.0"
77

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Thu Jun 13 21:57:28 EDT 2024
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
54
zipStoreBase=GRADLE_USER_HOME
65
zipStorePath=wrapper/dists

native/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ val artifactName = "luau-natives-${getOsName()}-${getArchName()}"
1515

1616
val buildProjectDir = file(layout.buildDirectory.file("root").get())
1717

18-
task<Copy>("copyForModification") {
18+
tasks.register<Copy>("copyForModification") {
1919
description = "Copy project to the build directory for modification"
2020
from(layout.projectDirectory)
2121
include("luau/**", "src/**", "CMakeLists.txt")
@@ -30,7 +30,7 @@ fun edit(file: File, edit: (String) -> String) {
3030
}
3131
}
3232

33-
task("luauStaticToShared") {
33+
tasks.register("luauStaticToShared") {
3434
description = "Make Luau.Compiler and Luau.VM compile as shared libraries"
3535
dependsOn("copyForModification")
3636

@@ -55,7 +55,7 @@ task("luauStaticToShared") {
5555
}
5656
}
5757

58-
task<Exec>("prepNative") {
58+
tasks.register<Exec>("prepNative") {
5959
dependsOn("luauStaticToShared")
6060
workingDir = file(layout.buildDirectory).resolve("cmake")
6161
standardOutput = System.out
@@ -82,7 +82,7 @@ task<Exec>("prepNative") {
8282
commandLine(args)
8383
}
8484

85-
task<Exec>("buildNative") {
85+
tasks.register<Exec>("buildNative") {
8686
dependsOn("prepNative")
8787
workingDir = file(layout.buildDirectory).resolve("cmake")
8888
standardOutput = System.out
@@ -97,7 +97,7 @@ task<Exec>("buildNative") {
9797
)
9898
}
9999

100-
task<Copy>("copyNative") {
100+
tasks.register<Copy>("copyNative") {
101101
dependsOn("buildNative")
102102

103103
var libPath = "cmake/lib" // todo it should definitely be a release build. need to do that.

settings.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
rootProject.name = "luau-java"
1+
plugins {
2+
id("org.gradle.toolchains.foojay-resolver-convention").version("0.10.0")
3+
}
24

5+
rootProject.name = "luau-java"
36
include("native")
7+

src/main/java/net/hollowcube/luau/LuaCallbacksImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import java.lang.foreign.MemorySegment;
66

7-
@SuppressWarnings("preview")
87
record LuaCallbacksImpl(@NotNull MemorySegment struct) implements LuaCallbacks {
98

109
}

0 commit comments

Comments
 (0)