Jump to content

Struggling with gradle dependencies


stepsword

Recommended Posts

So I have a soft dependency on GameStages where basically I am doing this:

 

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
    if (Loader.isModLoaded("gamestages")) {
        gamestages = new GameStagesLoadedProxy();
    } else {
        gamestages = new GameStagesProxy();
    }
}

 

GameStagesLoadedProxy has references to GameStage's helper class. 

 

In my gradle file I've added GameStages as a "provided" dependency, which from the description should just be an optional dependency. When I try to run the debug client in IntelliJ, though, it tries to load GameStages and complains about Bookshelf (a dependency of GameStages) not being loaded.

 

(net.minecraftforge.fml.common.MissingModsException: Mod gamestages (Game Stages) requires [bookshelf@[2.2.458,)])

 

I added Bookshelf as a provided dependency too, and get the same error. I also restarted IntelliJ and cleared the cache. I don't even know why GameStages is being loaded when I run it in the first place - it's a provided dependency which I thought would mean it doesn't get loaded unless I check the box "Include dependencies with Provided scope" which is not checked. 

 

Here is my full build.gradle file. Ideally I'd like to turn on and off whether GameStages runs when I'm debugging, but I'd settle for it both compiling and just not being included.. I just want to make sure I can debug the mod without any dependencies running at all, and can worry about doing it with dependencies from the twitch launcher.

 

Spoiler

 


buildscript {
    repositories {
        jcenter()
        maven { url = "https://files.minecraftforge.net/maven" }

    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
    }
}

repositories {

    maven { url = 'https://maven.mcmoddev.com' }
}

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


version = "1.2.0"
group = "stepsword.mahoutsukai" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "mahoutsukai"

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
    sourceCompatibility = targetCompatibility = '1.8'
}

minecraft {
    version = "1.12.2-14.23.5.2838"
    runDir = "run"
    
    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not always work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20171003"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

dependencies {
    // you may put jars on which you depend on in ./libs
    // or you may define them like so..
    //compile "some.group:artifact:version:classifier"
    //compile "some.group:artifact:version"
      
    // real examples
    //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
    //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // for more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html

    provided "net.darkhax.gamestages:GameStages-1.12.2:2.0.117"
    provided "net.darkhax.bookshelf:Bookshelf-1.12.2:2.3.588"

}

processResources {
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'
                
        // replace version and mcversion
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }
        
    // copy everything else except the mcmod.info
 //   from(sourceSets.main.resources.srcDirs) {
 //       exclude 'mcmod.info'
 //   }
}

 

 

 

 

 

Anyone have any experience with this?

Edited by stepsword
Link to comment
Share on other sites

2 hours ago, stepsword said:

As an update, running ".\gradlew idea" after "gradlew setupDecompWorkspace" fixed the bookshelf not loading issue, but I'm still having the "why is this even loading in the first place when it's set as 'provided' issue"

Even soft dependencies must be there at compile time. However it sounds like you are having problems with IntelliJ not working like you are supposed to have you looked around on other forums that are a out IntelliJ?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 minute ago, Animefan8888 said:

Even soft dependencies must be there at compile time. However it sounds like you are having problems with IntelliJ not working like you are supposed to have you looked around on other forums that are a out IntelliJ?

I haven't found anyone with a similar problem - the soft dependencies are there at compile time and the mod actually works both with and without the soft dependencies (after testing on Twitch). The "provided" keyword supposedly makes them optional at runtime. My main issue is that I can't seem to disable them at runtime in the intelliJ debug client (even though there seems to be a specific setting which ignores provided things at runtime). Well, I'll go look more at IntelliJ forums then, I realize this is more of a problem with IntelliJ than anything else but I was wondering if it was something specific to Minecraft since I don't really know at all how IntelliJ interacts with Forge to load mods in a debug environment 

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.