Jump to content

[1.12.2] Custom dependency not loaded.


suppergerrie2

Recommended Posts

Hello, I am working on a mod and I am using a custom dependency. I added the jar files according to the docs and used a build.gradle based on PaleoCrafter.

If I open the jar file I can see all of the .meta and .jar files and I can also see forge extracting them into the mods/1.12.2 folder. But when the game is launched the mod crashes during initialization due to 

java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
  Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper

It runs fine in intellij

This is my build.gradle:

buildscript {
    repositories {
        jcenter()
        maven { url = "https://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
    }
}

apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

version = "1.0"
group = "com.suppergerrie2.dependencytest"
archivesBaseName = "sdependencytest"

repositories {
    mavenLocal()
}

sourceCompatibility = targetCompatibility = '1.8'
compileJava {
    sourceCompatibility = targetCompatibility = '1.8'
}

minecraft {
    version = "1.12.2-14.23.5.2814"
    runDir = "run"
    
    mappings = "stable_39"
}

processResources {
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'

        expand 'version':project.version, 'mcversion':project.minecraft.version
    }

    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

//From https://github.com/PaleoCrafter/Dependency-Extraction-Example/blob/library-embedding/build.gradle
configurations {
    // Configuration that holds JARs to embed inside the mod JAR
    embed
    // Make embedded dependencies actually available during compilation/to IDEs
    compile.extendsFrom embed
}

dependencies {
    embed group: 'com.schematical.chaosnet', name: 'ChaosNet', version: '1.0-SNAPSHOT'
}

// Custom task to generate the metadata files required for our dependencies
task generateMetaFiles {
    // Code for execution after the whole buildscript was parsed and loaded
    doLast {
        // Clear the dependencyMeta directory since we don't want old dependencies to still be listed in there
        file("${buildDir}/dependencyMeta/").deleteDir()
        configurations.embed.resolvedConfiguration.resolvedArtifacts.each {
            // Create a meta file for each dependency in a specified directory
            def metaFile = file("${buildDir}/dependencyMeta/${it.file.name}.meta")
            metaFile.parentFile.mkdirs()
            // Use the Gradle notation provided by the API ('group:artifact:version') for the meta file...
            def artifactRef = it.moduleVersion.toString()
            // ...and append the classifier if present
            if (it.classifier != null) {
                artifactRef += ":${it.classifier}"
            }
            // Write the artifact information to the meta file, to be used by the
            metaFile.text = "Maven-Artifact: $artifactRef"
        }
    }
}

// Use the standard JAR task as container for the main jar and the contained dependencies (from the embed configuration)
jar {
    into('/META-INF/libraries/') {
        // Add all of the dependency JARs to the main JAR for later extraction
        from configurations.embed
        // Also include all dependency meta files
        from "${buildDir}/dependencyMeta/"
    }
    manifest {
        // The crucial manifest attribute: Make Forge extract the contained JARs
        attributes 'ContainedDeps': configurations.embed.collect { it.name }.join(' ')
    }
    // Only run the main jar task after the meta files were built
    dependsOn generateMetaFiles
}

And this is the only class in the mod:

package com.suppergerrie2.dependencytest;

import com.schematical.chaosnet.ChaosNet;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;

@Mod(modid = TestMod.MODID, name = TestMod.NAME, version = TestMod.VERSION)
public class TestMod {
    public static final String MODID = "sdependencytest";
    public static final String NAME = "Test Mod";
    public static final String VERSION = "1.0";

    private static Logger logger;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        logger = event.getModLog();

        ChaosNet sdk =  ChaosNet.builder()
                .build();

        logger.info(sdk);
    }

    @EventHandler
    public void init(FMLInitializationEvent event) {
    }
}

 

Edited by suppergerrie2
Link to comment
Share on other sites

  • 2 weeks later...

Does that specific class get put inside your jar and then extracted properly?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

What about that specific class?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I have no idea what could cause this, my best idea is to attach a debugger to the running minecraft instance and try and debug what’s causing it to fail

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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