-
-
Notifications
You must be signed in to change notification settings - Fork 447
Open
Description
My project is working on porting Jetpack Compose to Minecraft.
I'm using minecraftLibrary(compose.desktop.currentOs) to add dependencies as the wiki says,
but in runClient I always get ClassNotFounds or org.jetbrains.skiko.LibraryLoadException: Cannot find skiko-windows-x64.dll.sha256, proper native dependency missing.
That is, some transitive platform-dependent dependencies are not loaded into Minecraft runtime, such as org.jetbrains.skiko:skiko-awt-runtime-windows-x64:0.9.22.2 and org.jetbrains.compose.ui:ui-graphics-desktop:1.9.1, which is imported by compose gradle plugin depending on your development environment.
Here's my build script:
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.spongepowered.asm.gradle.plugins.struct.DynamicProperties
plugins {
idea
java
kotlin("jvm") version "2.2.20"
id("net.minecraftforge.gradle") version "[6.0.16,6.2)"
id("org.spongepowered.mixin") version "0.7-SNAPSHOT"
id("org.jetbrains.kotlin.plugin.compose") version "2.3.0"
id("org.jetbrains.compose") version "1.9.3"
}
group = property("mod_group_id")!!
version = property("mod_version")!!
base {
archivesName = property("mod_id").toString()
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
kotlin {
jvmToolchain(17)
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}
minecraft {
mappings(property("mapping_channel").toString(), property("mapping_version").toString())
copyIdeResources = true
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs {
configureEach {
workingDirectory(project.file("run"))
property("forge.logging.markers", "REGISTRIES")
property("forge.logging.console.level", "debug")
mods {
create(property("mod_id").toString()) {
source(sourceSets.main.get())
}
}
}
create("client") {
property("forge.enabledGameTestNamespaces", property("mod_id").toString())
}
}
}
mixin {
add(sourceSets.main.get(), "${findProperty("mod_id")}.refmap.json")
config("${findProperty("mod_id")}.mixins.json")
(debug as DynamicProperties).setProperty("verbose", true)
(debug as DynamicProperties).setProperty("export", true)
}
afterEvaluate {
tasks.named<JavaCompile>("compileJava") {
options.compilerArgs.add("-AoutRefMapFile=${project.layout.buildDirectory.get()}/resources/main/${findProperty("mod_id")}.refmap.json")
}
}
val library by configurations.creating
configurations {
named("library") {
isTransitive = true
isCanBeResolved = true
isCanBeConsumed = true
}
minecraftLibrary.get().extendsFrom(library)
}
repositories {
mavenCentral()
google()
// a private maven repository
maven { ... }
maven {
name = "Kotlin for Forge"
url = uri("https://thedarkcolour.github.io/KotlinForForge/")
}
maven {
url = uri("https://api.modrinth.com/maven")
}
}
dependencies {
minecraft("net.minecraftforge:forge:${property("minecraft_version")}-${property("forge_version")}")
library("...") // own util library, in private maven
// compose
library(compose.desktop.currentOs) {
exclude("org.jspecify")
}
implementation(fg.deobf("maven.modrinth:in-game-account-switcher:DCMEYBKC"))
annotationProcessor("org.spongepowered:mixin:0.8.7:processor")
}
sourceSets.configureEach {
val dir = layout.buildDirectory.dir("sourcesSets/$name")
output.setResourcesDir(dir)
java.destinationDirectory.set(dir)
kotlin.destinationDirectory.set(dir)
}
tasks.processResources {
var replaceProperties = mapOf(
"minecraft_version" to findProperty("minecraft_version"),
"minecraft_version_range" to findProperty("minecraft_version_range"),
"forge_version" to findProperty("forge_version"),
"forge_version_range" to findProperty("forge_version_range"),
"loader_version_range" to findProperty("loader_version_range"),
"mod_id" to findProperty("mod_id"),
"mod_name" to findProperty("mod_name"),
"mod_license" to findProperty("mod_license"),
"mod_version" to findProperty("mod_version"),
"mod_authors" to findProperty("mod_authors"),
"mod_description" to findProperty("mod_description")
)
inputs.properties(replaceProperties)
filesMatching(listOf("META-INF/mods.toml", "pack.mcmeta")) {
expand(replaceProperties + mapOf("project" to project))
}
}
tasks.jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
manifest {
attributes(
"Specification-Title" to findProperty("mod_id"),
"Specification-Vendor" to findProperty("mod_authors"),
"Specification-Version" to 1,
"Implementation-Title" to project.name,
"Implementation-Version" to project.tasks.jar.get().archiveVersion,
"Implementation-Vendor" to findProperty("mod_authors"),
)
}
library.forEach {
if (it.isDirectory) from(it)
else from(zipTree(it))
}
exclude("META-INF/versions/**", "module-info.class", "**/**.RSA")
exclude("META-INF/**.kotlin_module", "module-info.class", "**/**.RSA")
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA")
finalizedBy("reobfJar")
}
tasks.compileJava {
options.encoding = "UTF-8"
dependsOn(tasks.processResources)
}
Metadata
Metadata
Assignees
Labels
No labels