Jump to content

Recommended Posts

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.

Posted

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.

Posted

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

Posted

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.

Posted

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.

Posted

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.

Posted

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...

×   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.