Skip to content

[7.0] Package org.lwjgl:lwjgl-glfw is not exposed to compile-time on 1.18.2 #30

Open

Description

@VidTu

Code that uses GLFW (for example) won't compile. (Yes, I know that Mojang advises against it)

Quick and dirty compileOnly with org.lwjgl:lwjgl-glfw:3.2.2 fixes the issue.
1.19.2 (and also more new versions like 1.20.1, 1.21.1, 1.21.11, 26.1.2) are not affected.

I'm unsure if this is the right place to report or this is a userdev issue, I don't know about Forge's internals.

Gradle: 9.5.0
Forge: 1.18.2-40.3.12 (latest 1.18.2 at the time of writing)
ForgeGradle: 7.0.25
renamer (unneeded in fact for the sample code): 1.1.0

sample-project.zip

Activity

  1. LexManos commented on May 1, 2026

    @LexManos
    Member

    Okay, I think I understand the issue.
    For the compile classpath java selects the api-classes variant
    Specifically because it wants org.gradle.usage = java-api

    > Task :dependencyInsight
    net.minecraftforge:forge:1.18.2-40.3.12 (selected by rule)
      Variant api-classes:
        | Attribute Name                      | Provided     | Requested    |
        |-------------------------------------|--------------|--------------|
        | net.minecraftforge.mappings.channel | official     |              |
        | net.minecraftforge.mappings.version | 1.18.2       |              |
        | org.gradle.status                   | release      |              |
        | org.gradle.category                 | library      | library      |
        | org.gradle.dependency.bundling      | external     | external     |
        | org.gradle.jvm.environment          | standard-jvm | standard-jvm |
        | org.gradle.jvm.version              | 17           | 17           |
        | org.gradle.libraryelements          | jar          | classes      |
        | org.gradle.usage                    | java-api     | java-api     |
    

    We only publish one variant of api-classes with libraries that do not have an OS requirement.

    Now, why is that an issue on 1.18.2 and not on 1.20.1
    Well if you take a look at 1.18.2 their root glfw is different depending on the OS:
    3.2.1 on osx, and 3.2.2 on everything else.

        {
          "downloads": {
            "artifact": {
              "path": "org/lwjgl/lwjgl-glfw/3.2.1/lwjgl-glfw-3.2.1.jar",
              "sha1": "027abb7f64894b61cad163791acd8113f0b21296",
              "size": 116708,
              "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.2.1/lwjgl-glfw-3.2.1.jar"
            }
          },
          "name": "org.lwjgl:lwjgl-glfw:3.2.1",
          "rules": [
            {
              "action": "allow",
              "os": {
                "name": "osx"
              }
            }
          ]
        },
        {
          "downloads": {
            "artifact": {
              "path": "org/lwjgl/lwjgl-glfw/3.2.2/lwjgl-glfw-3.2.2.jar",
              "sha1": "d3ad4df38e400b8afba1de63f84338809399df5b",
              "size": 108907,
              "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.2.2/lwjgl-glfw-3.2.2.jar"
            }
          },
          "name": "org.lwjgl:lwjgl-glfw:3.2.2",
          "rules": [
            {
              "action": "allow"
            },
            {
              "action": "disallow",
              "os": {
                "name": "osx"
              }
            }
          ]
        },

    Whereas 1.20.1 uses the same glfw version for all OSes, just with the natives different by os.

        {
          "downloads": {
            "artifact": {
              "path": "org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1.jar",
              "sha1": "cbac1b8d30cb4795149c1ef540f912671a8616d0",
              "size": 128801,
              "url": "https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.3.1/lwjgl-glfw-3.3.1.jar"
            }
          },
          "name": "org.lwjgl:lwjgl-glfw:3.3.1"
        },

    So, the 'fix' is to publish OS specific variants and make sure that the dependency requests the OS specific variants.

    When i get some free time i'll look into implementing it unless Jonathing wants to poke it first.
    Main thing is I need to make sure that the compileClasspath has the OS attribute set on the gradle side.
    And then rework this function to know what is a native file and what is an actual library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions