Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeoGradle fails to resolve dependencies with version ranges #84

Closed
FiniteReality opened this issue Dec 22, 2023 · 1 comment · Fixed by #176
Closed

NeoGradle fails to resolve dependencies with version ranges #84

FiniteReality opened this issue Dec 22, 2023 · 1 comment · Fixed by #176
Labels
bug Something isn't working

Comments

@FiniteReality
Copy link
Member

If you specify a version range for the NeoForge dependency, NeoGradle fails to resolve dependencies correctly, leading to a broken configuration when you try to build or run the project. As an example, using a freshly cloned version of the MDK with a small modification:

dev@Monica:~/tmp/MDK (main)*$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   build.gradle

no changes added to commit (use "git add" and/or "git commit -a")
dev@Monica:~/tmp/MDK (main)*$ git diff
diff --git a/build.gradle b/build.gradle
index 6f1f2ca..a4717ca 100644
--- a/build.gradle
+++ b/build.gradle
@@ -80,7 +80,7 @@ dependencies {
     // You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
     // And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
     // For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
-    implementation "net.neoforged:neoforge:${neo_version}"
+    implementation("net.neoforged:neoforge:[20.4,)")
 
     // Example mod dependency with JEI
     // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
dev@Monica:~/tmp/MDK (main)*$ ./gradlew build
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/8.1.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build 
Path for java installation '/usr/lib/jvm/openjdk-17' (Common Linux Locations) does not contain a java executable
Path for java installation '/usr/lib/jvm/openjdk-16' (Common Linux Locations) does not contain a java executable
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find any version that matches ng_dummy_ng.net.neoforged:neoforge:[20.4,).
     Versions that do not match: [20.4,)
     Searched in the following locations:
       - file:/home/dev/tmp/MDK/.gradle/repositories/ng_dummy_ng/net/neoforged/neoforge/
       - https://libraries.minecraft.net/ng_dummy_ng/net/neoforged/neoforge/
       - https://maven.neoforged.net/releases/ng_dummy_ng/net/neoforged/neoforge/maven-metadata.xml
       - file:/home/dev/.m2/repository/ng_dummy_ng/net/neoforged/neoforge/
     Required by:
         project :

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
33 actionable tasks: 1 executed, 32 up-to-date
dev@Monica:~/tmp/MDK (main)*$ ls /home/dev/tmp/MDK/.gradle/repositories/ng_dummy_ng/net/neoforged/neoforge/
'[20.4,)'

Looking at the contents of the [20.4,) folder, there's a neoforge-[20.4,).jar whose manifest appears to match 20.4.48-beta, which suggests the resolution is working correctly, but somewhere the version constraint is getting mangled and reinterpreted as a full version number:

Manifest-Version: 1.0
FML-System-Mods: neoforge

Name: net/neoforged/neoforge/versions/neoform/
Specification-Title: Minecraft
Specification-Vendor: Mojang
Specification-Version: 1.20.4
Implementation-Title: MCP
Implementation-Version: 1.20.4-20231207.154220
Implementation-Vendor: NeoForged

Name: net/neoforged/neoforge/internal/versions/neoforge/
Specification-Title: NeoForge
Specification-Vendor: NeoForge
Specification-Version: 20.4
Implementation-Title: net.neoforged
Implementation-Version: 20.4.48-beta
Implementation-Vendor: NeoForged

Ideally, NeoGradle should detect that this is a version constraint and use the resolved version, or at the very least it should be documented that version constraints are not supported.

@FiniteReality
Copy link
Member Author

This also applies to rich versions, which is how I found this bug in the first place (using a strictly/prefer so that i could specify versions in one place and have them flow into my mods.toml cleanly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants