bergerhealer / Mountiplex

General Purpose Java Reflection Library
MIT License
10 stars 4 forks source link

Depending on mountiplex module will cause build failed on first attempt #14

Open LeeGodSRC opened 2 months ago

LeeGodSRC commented 2 months ago

So I have a multi-module project structured like this: plugin -> nms (mountiplex)

And on the first attempt of building, it always throw this exception

* What went wrong:
A problem was found with the configuration of task ':plugin:compileJava' (type 'JavaCompile').
  - Gradle detected a problem with the following location: '/home/leegod/Documents/ideaProjects/raytraced-antixray-bukkit-plugin/nms/modern/build/classes/java/main'.

    Reason: Task ':plugin:compileJava' uses this output of task ':nms:modern:remapAnnotations' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':nms:modern:remapAnnotations' as an input of ':plugin:compileJava'.
      2. Declare an explicit dependency on ':nms:modern:remapAnnotations' from ':plugin:compileJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':nms:modern:remapAnnotations' from ':plugin:compileJava' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.6/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
bergerkiller commented 2 months ago

Strangely the solution for this was already applied here:

https://github.com/bergerhealer/Mountiplex/blob/master/mountiplex-gradle-plugin/src/main/java/com/bergerkiller/mountiplex/gradle/MountiplexPlugin.java#L29C28-L29C45

So it should just work. Is something special about your configuration that it might not match logic? Im not a big expert on gradle things

The way Ive used it is: https://github.com/bergerhealer/BKCommonLib/blob/master/build.gradle.kts#L144

And this hasnt given me issues yet

mountiplex {
    remapAnnotationStrings()
}

If doing ^ doesnt fix it, maybe you can create a minimum reproducing example so I can test it myself?

LeeGodSRC commented 2 months ago

I will try to recreate a reproducing example, but I figured a way to solve it. You need to manually specify task dependency in the project for example:

:nms:modern is the project that contains mountiplex, and you will need to do

    named("compileJava") {
        mustRunAfter(":nms:modern:remapAnnotations")
    }