Posted April 10, 20169 yr 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.
April 10, 20169 yr JarShadow. Same way you include APIs. 1.7.10 is no longer supported by forge, you are on your own.
April 10, 20169 yr 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
April 14, 20169 yr 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.
April 14, 20169 yr 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
April 14, 20169 yr 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.
April 14, 20169 yr Make sure you're using the latest version of Gradle and the latest version of Shadow. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
April 16, 20169 yr Author To update grade would I use the latest version of ForgeGradle? Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.
April 16, 20169 yr No, you would install the latest version of Gradle from the Gradle site and run gradle wrapper . Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
April 16, 20169 yr Author Where do I install the newest version of Gradle? Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.
April 17, 20169 yr 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.
April 17, 20169 yr 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.
April 17, 20169 yr You need to include commons math as a Maven dependency and tell Shadow to include it in your jar, otherwise the relocate bit doesn't do anything. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
April 18, 20169 yr 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.