Jump to content

Multi-module Forge Project


MadMartian

Recommended Posts

I am working on decoupling my monolithic mod project into multiple mod modules within the same workspace.  I haven't been able to find any documentation on whether this is even possible with Minecraft Forge, so that may be a quick answer to this question.  Everything appears to work fine except there are strange issues that don't add up (such as it can't resolve my language file for a sub-module).  I have also been unable to find any errors in the output log except for one error that claims it's not an error ::).

 

Prior to decoupling my mod everything was working fine as far as I know (I didn't experience any strange issues), and my automated build pipeline fails fast most of the time to catch such things anyway.  At the end of the day I deploy this mod on a standalone CentOS VPS, so if something can go wrong there are plenty of opportunities for issues to crop up, but none have before I started this decoupling exercise.

 

What I want to do is basically as follows: I have a gradle project that contains sub-modules one of which is a Minecraft Forge mod called siaca.  The root-level module (that is the parent for everything) is also a Minecraft Forge mod (perhaps I need to make that a sub-module too though?).  The root module mod uses a oneJar task to bundle everything up into a single Jar, but it the sub-module mod is not a dependency of the root module mod (and I'll tell you why later).

 

My settings.gradle

rootProject.name = "MadMartianMod"
include 'asm-toolkit'
include 'data-structures'
include 'foo-stuff'
include 'siaca'

 

Main Root Module Mod build.gradle

buildscript {
    repositories {
        mavenCentral()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
    }
}

apply plugin: 'forge'

version = "5.6.15-Lime"
group= "mad-martian"

configurations {
    mods    // Dependencies that may or may not be present during runtime but are always visible during development

    // This configuration replaces the default compile configuration for my project
    family {
        // These aren't being used anywhere and aren't part of the server installation
        exclude group: 'org.scala-lang'
        exclude group: 'org.scala-lang.plugins'
        exclude group: 'org.scala-lang.modules'
        exclude group: 'com.typesafe'
        exclude group: 'com.typesafe.akka'
    }

    compile {
        extendsFrom family
    }

    // This configuration is for bundling all module class files into a single JAR for deployment
    bundle {
        extendsFrom family

        // These are used during development but aren't present in the server installation
        exclude group: 'com.ibm.icu', name: 'icu4j-core-mojang'
        exclude group: 'org.ow2.asm', name: 'asm-debug-all', version: '5.0.3'
    }
}

task onejar(type: Jar) {
    manifest.from jar.manifest

    from {
        configurations.bundle.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }

    with jar
}

artifacts {
    archives onejar
}

minecraft {
    version = "1.7.10-10.13.4.1558-1.7.10"
    runDir = "working"
}

dependencies {
    testCompile "junit:junit:4.6"
    testCompile group: "org.apache.logging.log4j", name: "log4j-core", version: "2.3"
    testCompile group: "org.mockito", name: "mockito-core", version: "1.10.19"

    // Take advantage of the recipe GUI API
    mods files("modlibs/CraftGuide-1.6.8.2-forge.jar")

    // Workspace dependencies
    family project(':foo-stuff')
    family project(':asm-toolkit')
}

sourceSets.main.compileClasspath += [ configurations.mods ]

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, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

runClient {
    systemProperties "mad-martian-mod.mutations.strict": true, "log4j.configurationFile": "../dev-log4j2.xml"
    jvmArgs "-Xmx2048m", "-Xms1024m"
}

runServer {
    systemProperties "mad-martian-mod.mutations.strict": true, "log4j.configurationFile": "../dev-log4j2.xml"
    jvmArgs "-Xmx2048m", "-Xms1024m"
}

idea {
    module {
        name = 'MadMartian Mod'
        jdkName = '1.7'
        excludeDirs = [
            file(".gradle"),
            file(".idea"),
            file("logs"),
            file("build"),
            file("working"),
            file("gradle")
        ]
        scopes.PROVIDED.plus += [ configurations.mods ]
    }
}

 

 

Sub-Module Mod siaca - build.gradle


buildscript {
    repositories {
        mavenCentral()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            name = "sonatype"
            url = "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
    }
}

group="mad-martian"
version '0.1'

apply plugin: 'forge'

sourceCompatibility = 1.6

minecraft {
    version = "1.7.10-10.13.4.1558-1.7.10"
    runDir = "../working"
}

dependencies {
    testCompile "junit:junit:4.6"
    testCompile group: "org.apache.logging.log4j", name: "log4j-core", version: "2.3"
    testCompile group: "org.mockito", name: "mockito-core", version: "1.10.19"

    // Configuration file model
    compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.8.5'

    compile project(':data-structures')
    compile project(':asm-toolkit')
}

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, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

idea {
    module {
        jdkName = '1.7'
    }
}

 

Here are the problems I am running into:

[*]Running the task runClient on the root module starts two instances of Minecraft, one for each mod in the workspace (I guess that could indicate the need to make the root mod a sub-module, will that work?)

[*]My sub-module cannot find the lang file, I have checked several times to make sure it is correct while the root mod's lang file works fine.  It isn't obvious to me why it can't find it.  The language file is stored at (I copied and pasted the path to eliminate the risk of typos): < workspace root > /siaca/src/main/resources/assets.siaca.lang/en_US.lang

[*]When step-debugging the sub-module in runtime, the Minecraft compiled code is out of sync with its source mapping (i.e. I set a breakpoint on some line but the program either misses it completely, stops in some strange unexpected place in the program.  Also when step-debugging it appears as if the current execution point passes over comments and white space)

 

Some specific questions I have:

[*]Is it possible to do this? have one workspace with multiple mods contained within it? or do I have to create a completely separate workspace for each mod? (that would be undesirable as both depend on shared sub-modules)

[*]How does one make Minecraft utility modules that are shared by other mod modules?  At one point I tried making foo-stuff a mod as well and then tried to make it a dependency of the root mod because I wanted to pull-out common Minecraft code into a utility module.  I couldn't run the root mod because it would fail with a "failed to download Minecraft Forge" error required by foo-stuff and I noticed something very strange about the URL it was trying to download from, it was libraries.minecraft.net and the artifact-id and version was present in the URL but where the group-id should have been there were just two slashes instead: '//'

 

Any help or insight on troubleshooting these issues would be greatly appreciated.

  • Like 1
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.