FINALLY offline build SHOULD work

This commit is contained in:
alexcrea 2026-01-10 19:09:03 +01:00
parent 474ad0f1b2
commit 4ed9de3d3c
Signed by: alexcrea
GPG key ID: E346CD16413450E3

View file

@ -140,30 +140,21 @@ allprojects {
} }
tasks { tasks {
// Online jar (use of libraries) fun ShadowJar.configureBaseShadow(suffix: String, libraries: Array<String>) {
shadowJar { val processedSuffix = if(suffix.isEmpty()) "" else "-$suffix"
// No suffix for this jar val name = "${rootProject.name}-${effectiveVersion}${processedSuffix}.jar"
val name = "${rootProject.name}-${effectiveVersion}.jar"
archiveFileName.set(name) archiveFileName.set(name)
// Exclude kotlin std, annotations and adventure api
exclude("*kotlin/**")
exclude("**/annotations/**")
exclude("net/kyori/**")
// Shadow necessary dependency // Shadow necessary dependency
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.inventoryframework") relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.inventoryframework")
// Replace version and example fields in plugin.yml
filesMatching("plugin.yml") { filesMatching("plugin.yml") {
expand( expand(
"version" to effectiveVersion, "version" to effectiveVersion + processedSuffix,
"libraries" to " \"org.jetbrains.kotlin:kotlin-stdlib:2.1.0\"" + "libraries" to libraries.joinToString(transform = { "\"$it\"" }),
", \"net.kyori:adventure-text-minimessage:4.25.0\"" +
", \"net.kyori:adventure-text-serializer-plain:4.25.0\"" +
", \"net.kyori:adventure-text-serializer-legacy:4.25.0\""
) )
} }
@ -171,36 +162,28 @@ tasks {
dependsOn(processResources) dependsOn(processResources)
} }
// Offline jar (include kotlin std in the final jar fine) // Online jar (use of libraries)
val offlineJar by // Shadow necessary dependency shadowJar {
registering( configureBaseShadow("",
arrayOf(
"org.jetbrains.kotlin:kotlin-stdlib:2.1.0",
"net.kyori:adventure-text-minimessage:4.25.0",
"net.kyori:adventure-text-serializer-plain:4.25.0",
"net.kyori:adventure-text-serializer-legacy:4.25.0",
))
// Include all project other dependencies // Exclude kotlin std, annotations and adventure api
ShadowJar exclude("*kotlin/**")
exclude("**/annotations/**")
exclude("net/kyori/**")
}
// Add custom anvil compiled val offlineJar by registering(ShadowJar::class) {
::class, fun ShadowJar.() { configureBaseShadow("offline", emptyArray())
val name = "${rootProject.name}-${effectiveVersion}-offline.jar"
archiveFileName.set(name)
// Shadow necessary dependency from(sourceSets.main.get().output)
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.inventoryframework") configurations = listOf(project.configurations.runtimeClasspath.get())
}
filesMatching("plugin.yml") {
expand(
"version" to "$effectiveVersion-offline",
"libraries" to ""
)
}
// Include all project other dependencies
from(project.configurations.runtimeClasspath)
// Add custom anvil compiled
from(sourceSets.main.get().output)
dependsOn(processResources)
})
// Make the online and offline jar on build // Make the online and offline jar on build
named("build") { named("build") {