Jump to content

[1.7.10] Gradle packaging dependencies into mod jar.


SuperKael

Recommended Posts

Exactly what the title says. My mod, called BottleOBlood runs fine, everything seems normal, but after a compile, I have to go into the created jar and deleted the folders named "enviromine" and "cofh" because they have been packaged into my jar. There are no errors or anything in the compile, and it runs fine in the dev environment. I noticed that in the build/classes/main folder, the cofh and enviromine folders are being put there during the compile. My file structure is as follows:

 

Mod Root/
    asm/
        (random stuff)
    assets/
        (heavily obfuscated stuff)
    bin/
        1.7.10/
            (CodeChickenLib jar, copied by the dev environment from my mods folder)
        assets/
            bottleoblood/
                (My Mod's assets)
            cofh/
                (CoFHCore's assets)
            enviromine/
                (Enviromine's assets)
        bottleoblood/
            (My Mod's libraries)
        cofh/
            (CoFHCore's libraries)
        enviromine/
            (Enviromine's libraries)
        Changelog.txt
        mcmod.info
        (All the jars within my mods folder)
    build/
        classes/
            main/
                bottleoblood/
                    (My Mod's libraries)
                cofh/
                    (CoFHCore's libraries)
                enviromine/
                    (Enviromine's libraries)
        dependency-cache/
            (Empty)
        libs/
            (The mod jars for the different versions- I am keeping old versions here)
        natives/
            (Various .dll's that I am guessing are core libraries of some sort)
        resources/
            (all the stuff from my resources folder in src- no reference to CoFHCore or Enviromine here)
        sources/
            java/
                bottleoblood/
                    (The source files for my mod)
        tmp/
            (Various random stuff used during compile, nothing relevant here)
    config/
        (The mod config files for running my mod in the dev environment)
    crash-reports/
        (Crash reports produced during testing in my dev enviroment)
    eclipse/
        (Empty folder- can't figure out what it's for. Created during dev environment setup)
    gradle/
        wrapper/
            gradle-wrapper.jar
            gradle-wrapper.properties
    libs/
        (This folder is added to the Build Path for my mod)
        assets/
            cofh/
                (CoFHCore's assets)
            enviromine/
                (Enviromine's assets)
        cofh/
            (CoFHCore's libraries)
        enviromine/
            (Enviromine's libraries)
        CoFHCore.jar
        Enviromine.jar
        (The two above jars contained the source for their referenced mods, used in the build.gradle)
    logs/
        (The log files produced during testing within the dev environment)
    mod resources/
        (Various mods that I have additional compatability for, but only if they are present. when not in use, I store them here, to reduce how long it takes to start up the dev environment)
    mods/
        (Mods actively used in the dev environment)
    resourcepacks/
        (Empty folder- would hold resourcepacks for the dev environement)
    saves/
        (Saves created while testing in the dev environment)
    src/
        main/
            java/
                bottleoblood/
                    (My Mod's source files)
            resources/
                assets/
                    bottleoblood/
                        (My Mod's assets)
                Changelog.txt
                mcmod.info

 

And my 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 = "1.7.10-1.4-Stable"
group = "bottleoblood" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "BottleOBlood"

minecraft {
    version = "1.7.10-10.13.2.1230"
    runDir = "eclipse"
}

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

    // for more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html
    
compile files("libs/CoFHCore.jar")
    compile files("libs/EnviroMine.jar")
}

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'
    }
}

 

Sorry for all this info, this is probably a bit more than you need, but I have no clue what the issue is, so I thought I would just put everything. please help any way you can.

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

Link to comment
Share on other sites

That can't be your entire build file.

 

The default one Forge ships looks like this:

 

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 = "1.0"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"

minecraft {
    version = "1.7.10-10.13.2.1352-1.7.10"
    runDir = "eclipse"
}

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

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

}

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'
    }
}

 

The important bit here, is

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

 

You can exclude more things there, if you need to.

 

Say

 

    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info','enviromine/**','cofh/**'
    }

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

[*]This is my entire build file

[*]I will try the exclusion thing

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

Link to comment
Share on other sites

I added what you suggested to the build file, did nothing.

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

Link to comment
Share on other sites

This is my entire build file

 

Apologies, for some reason I missed the scroll bar before.  I remember even checking twice to see if there was more (as I was seeing only the one section).

 

I added what you suggested to the build file, did nothing.

 

Hmm.  Ok then.  Try adding this:

 

task exclusionBuild(type: Jar) {
    baseName = archivesBaseName+"_noAPIs"

    from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
        exclude 'mcmod.info','enviromine/**','cofh/**'
    }
}
exclusionBuild.dependsOn('reobf')

 

Then, instead of "gradlew build" do "gradlew build exclusionBuild"

 

(You can name the task whatever you'd like, of course).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I used your sudgestion code, and it worked! although I want to see if there is anyway I can bypass the extra paramater to the command

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

Link to comment
Share on other sites

Honestly, no idea.  I managed to get that, due to having multiple jar files I wish to publish (so I have a task for each one).  Not sure why you're getting what you're getting with the regular build, and I don't know enough about the build scripts to know how to tweak the default task.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.