FabricMC / fabric-language-kotlin

Fabric language module for Kotlin.
Apache License 2.0
299 stars 33 forks source link

Unable to use in dev environment #32

Closed F0Xde closed 3 years ago

F0Xde commented 3 years ago

I am not sure what exactly causes this, but since today all of a sudden I cannot run the game using the gradle runClient task, as it complains about the required mod missing

Mod 'My Mod' (mymod) requires any version of mod fabric-language-kotlin, which is missing!

I've tried with the the minimum version and without (as you can see above), but the mod is seen as missing regardless.

Adding the mod to the run/mods directory also does not work, as then it seems to be loaded twice:

Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "kotlin/jvm/functions/Function1"
F0Xde commented 3 years ago

Here is my complete build.gradle.kts if thats of any help, although I believe there is nothing special in there:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.4.21"
    id("fabric-loom") version "0.5-SNAPSHOT"
    id("com.github.ben-manes.versions") version "0.36.0"
}

group = "my.mod"
version = "0.0.1"

repositories {
    jcenter()
    maven("https://maven.fabricmc.net/")
}

dependencies {
    minecraft("com.mojang:minecraft:1.16.4")
    mappings("net.fabricmc:yarn:1.16.4+build.7:v2")
    modImplementation("net.fabricmc:fabric-loader:0.10.8")
    modImplementation("net.fabricmc:fabric-language-kotlin:1.4.21+build.1")
    modImplementation("net.fabricmc.fabric-api:fabric-api:0.28.4+1.16")

    modImplementation("io.ktor:ktor-client-cio-jvm:1.5.0")
    modImplementation("io.ktor:ktor-client-gson:1.5.0")
// After fiddling around with this stuff I couldn't run the client anymore, but removing it still leads to the same error
//    includeKtor(configurations.modImplementation.get().resolvedConfiguration.firstLevelModuleDependencies)
}

fun DependencyHandlerScope.includeKtor(dependencies: Set<ResolvedDependency>) {
    for (dep in dependencies) {
        dep.children
        if (dep.moduleGroup == "io.ktor") {
            include(dep.name)
            includeKtor(dep.children)
        }
    }
}

val javaVersion = JavaVersion.VERSION_1_8

java {
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    withSourcesJar()
}

tasks {
    withType<KotlinCompile> {
        kotlinOptions.jvmTarget = javaVersion.toString()
    }

    processResources {
        inputs.property("version", project.version)

        filesMatching("fabric.mod.json") {
            expand("version" to project.version)
        }
    }
}
F0Xde commented 3 years ago

Well I still have no idea wtf happened there, but after deleting the complete .gradle cache and build dir it is again working as expected. Sorry to have bothered you