PaperMC / paperweight

Gradle build system plugin for Paper and Paper forks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in multi gradle module

cosmohdx opened this issue · comments

If you use paperweight in mutli module project its working until paperweight is implemented in a second module in the same project.

settings.gradle.kts

include("shared")
include("bukkit")
include("bukkit-mixin")
include("service")

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven("https://repo.papermc.io/repository/maven-public/")
    }
}

the projects bukkit and bukkit-mixin have implemented paperweight.

plugins {
  id("com.github.johnrengelman.shadow") version "7.1.2"
  id("io.papermc.paperweight.userdev") version "1.3.8"
}

dependencies {
  paperDevBundle("1.19.2-R0.1-SNAPSHOT")
}

When adding paperweight to the first module, all is working well.
When adding to the second module, this error occures:

class io.papermc.paperweight.userdev.internal.setup.UserdevSetup$Inject cannot be cast to class io.papermc.paperweight.userdev.internal.setup.UserdevSetup (io.papermc.paperweight.userdev.internal.setup.UserdevSetup$Inject is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @534a0a01; io.papermc.paperweight.userdev.internal.setup.UserdevSetup is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @660d1a82)
class io.papermc.paperweight.userdev.internal.setup.UserdevSetup$Inject cannot be cast to class io.papermc.paperweight.userdev.internal.setup.UserdevSetup (io.papermc.paperweight.userdev.internal.setup.UserdevSetup$Inject is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @534a0a01; io.papermc.paperweight.userdev.internal.setup.UserdevSetup is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @660d1a82)

You will need to configure the paperweight plugin in your root module with apply false. E.g:

plugins {
  id("io.papermc.paperweight.userdev") version "1.3.8" apply false
}

in your root build.gradle.kts

and then

plugins {
  id("io.papermc.paperweight.userdev")
}

in your modules build.gradle.kts

I'll close this as I believe we have been telling developers to set it up this way for a while. If someone is willing to try to fix this, I can reopen this issue as a tracking issue for progress made.

If someone is willing to try to fix this, I can reopen this issue as a tracking issue for progress made.

This is a gradle issue, there is nothing we can do from our side

Ah sweet, TIL 👍