Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello,

I am using the Reflections library for my mod. However, when I try to include it using the old ContainedDeps method in 1.18.1, it seems to not work anymore.

Am I doing something wrong, or is this method obsolete now? Should I use shading instead?

pack-libs.gradle

// Create configuration
configurations {
    packLib
    implementation.extendsFrom packLib
}

// afterEvaluate is necessary so that packLib isn't resolved before it is used
afterEvaluate {
    jar {
        // Copy libraries
        from (configurations.packLib) {
            into 'META-INF/libraries'
        }

        // Add libraries into manifest
        //noinspection GroovyAssignabilityCheck
        manifest {
            attributes([
                    "ContainedDeps": configurations.packLib.collect { it.name}.join(' ')
            ])
        }
    }
}

build.gradle

...

// Allows us to pack libraries into jar to be loaded by forge
apply from: 'pack-libs.gradle'

...

dependencies {
    ...
    packLib 'org.reflections:reflections:0.10.2'
}


To clarify, I'm not getting a compilation error, I'm getting a NoClassDefFoundError.
Also, when I build the jar and check inside it, the jars do seem to be there in META-INF/libraries and the ContainedDeps is correct:

ContainedDeps: reflections-0.10.2.jar javassist-3.28.0-GA.jar jsr305-3
 .0.2.jar slf4j-api-1.7.32.jar


 

Edited by Majd123mc

  • Majd123mc changed the title to [CLOSED] [1.18.1] META-INF/libraries not working
  • Author

@noSkill
 

8 hours ago, noSkill said:

So how to include dependencies?


You will have to create a fat jar instead.

A quick google search will show you plenty of results.

HOWEVER, in 1.18.1 ANY external dependencies, when debugging using the debug tool in IntelliJ, the libraries don't load AT ALL. Which has nothing to do with fat-jaring and is a *bug*.

But if you want to package other libraries in your mod, you will need to create a fat jar. I've found this resource to be useful: https://gist.github.com/Commoble/ddc75e819a690198c15d26564d139333

*P.S. I was not able to test if the Jar-in-Jar method works still, it MAY work in 1.18.1 but I cannot verify that because of the bug. There is a chance it still works so you can test it out and if it works for you, great! If it doesn't, then use the fat jar method instead.*

Shadow plugin didn't work for me. It gave some errors on launch saying that my module both requires and exports the same packages. My current approach is to add only certain dependencies manually:
 

dependencies {

minecraft 'net.minecraftforge:forge:1.18.1-39.0.59'

        jar { from { configurations.compileClasspath.findAll { (it.name.endsWith('jar') && !it.name.contains('forge')) }.collect {  zipTree(it) } }

}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.