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

I want to use the math library from apache commons. However, just including it in the build path doesn't include it in the build. I don't want to just use the sources in my mod because that could create compatibility issues (I'm assuming some other mods use commons math). How do I include it in my build?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

JarShadow. Same way you include APIs.

1.7.10 is no longer supported by forge, you are on your own.

Same way as how I told you in your previous thread about shading. Use the Shadow plugin, tell it to include you're version of Commons Math and tell it to relocate it to a package inside your mod package.

 

You can see an example of this here.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

  • Author

So would I just use

relocate "org.apache.commons.math3", "my package here"

?

 

If so, where do I put the org.apache.commons.math3, and when I relocate it into my package in my mod, how do I make my mod files reference Commons Math when it hasn't been relocated to that package yet (in the dev environment)?

 

Thanks

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Yes, what i usually do is:

 

relocate "org.apache.commons.math3", "your.mod.package.repack.org.apache.commons.math3"

 

The whole point of having the

relocate

function is that it both moves the files and updates all the references in your code and in the other library.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

  • Author

Thanks!

 

I still get a NoClassDefFoundError for org.gradle.api.plugins.JavaPlugin, is there something else I need to do?

 

build.gradle

 

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

plugins{
    id "com.github.johnrengelman.shadow" version "1.2.2"
}

apply plugin: "net.minecraftforge.gradle.forge"

version = "1.0"
group= "com.apmods.hpspells" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "hpspells"

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

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

shadowJar{
    relocate "org.apache.commons.math3", "com.apmods.hpspells.repack.org.apache.commons.math3"
}


 

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

  • Author

To update grade would I use the latest version of ForgeGradle?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

  • Author

Where do I install the newest version of Gradle?

 

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

  • Author

Ok, I updated gradle to version 2.12 and that is working, however when I run

gradlew build

it comes up with this error.

 

> Failed to apply plugin [class 'com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin']
   > Could not create task of type 'ShadowJar'.

 

 

Here is my build.grade, what am I doing wrong?

 

buildscript {
    repositories {
        jcenter()
        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'
    }
}

plugins{
id "com.github.johnrengelman.shadow" version "1.2.2"
}

apply plugin: 'java'
apply plugin: "com.github.jengelman.gradle.plugins.shadow"
apply plugin: 'forge'

version = "1.0"
group= "com.apmods.hpspells" 
archivesBaseName = "hpspells"

minecraft {
    version = "1.7.10-10.13.4.1558-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'
    }
}

shadowJar{
    relocate "org.apache.commons.math3", "com.apmods.hpspells.repack.org.apache.commons.math3"
}

 

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

  • Author

Ah, silly mistake, it was a bug in version 1.2.2 of shadowJar, I updated to 1.2.3 and it was fixed.

 

However, now when I run it it throws several errors because it can't find any of the apache commons math classes. My build.gradle is posted above. I have added apache commons math3 as an external jar to Minecraft's build path. Any help would be appreciated.

 

Thanks

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

  • Author

Thanks! That worked. Here is my build.grade for anyone wondering.

 

buildscript {
    repositories {
        jcenter()
        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'
    }
}

plugins{
id "com.github.johnrengelman.shadow" version "1.2.3"
}

apply plugin: 'java'
apply plugin: 'forge'

version = "1.0"
group= "com.apmods.hpspells" 
archivesBaseName = "hpspells"

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

dependencies {
    compile group: "org.apache.commons", name: "commons-math3", version: "3.2"
}

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

shadowJar{
    relocate "org.apache.commons.math3", "com.apmods.hpspells.repack.org.apache.commons.math3"
}

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

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.