Jump to content

External Dependency does not work in Normal MC


KingofGamesYami

Recommended Posts

I've found several posts in various places about this, but the syntax in every case is outdated.  I am shading JGit.  It and it's dependencies end up in my jar, but slf4j crashes on launch causing general horribleness.

 

Spoiler

buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.

version = "2.0"
group= "org.kingofgamesyami.ccgit" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ccgit"

sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly.
compileJava {
    sourceCompatibility = targetCompatibility = "1.6"
}

minecraft {
    version = "1.10.2-12.18.3.2316"
    runDir = "run"
    
    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161111"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    //something that might help?
}

configurations {
    shade
    compile.extendsFrom shade
}

repositories {
    maven { url = "https://crzd.me/files/maven/" }
    maven { url = "https://dl.bintray.com/squiddev/maven" }
    maven { url = "https://repo.eclipse.org/content/groups/releases/" }
}

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"

    compile "dan200.computercraft:ComputerCraft:1.80pr0-build0"
    compile "org.squiddev:CCTweaks:1.10.2-1.5.0-pr0:dev"

    shade 'org.eclipse.jgit:org.eclipse.jgit:4.5.0.201609210915-r'

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

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

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

}

jar {
    configurations.shade.each { dep ->
        from(project.zipTree(dep)){
            exclude 'META-INF', 'META-INF/**'
        }
    }
}

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

 

 

Edited by KingofGamesYami
Link to comment
Share on other sites

Trying shadow out, gradlew build no longer functions.  Repeated "error: package org.eclipse.jgit.api does not exist" for all imports.  I have no idea what I'm doing wrong, as I followed the shadow introduction exactly and nothing seems to be wrong with my build.gradle...

 

Spoiler

buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
    }
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.

version = "2.0"
group= "org.kingofgamesyami.ccgit" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ccgit"

sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly.
compileJava {
    sourceCompatibility = targetCompatibility = "1.6"
}

minecraft {
    version = "1.10.2-12.18.3.2316"
    runDir = "run"
    
    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161111"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    //something that might help?
}

repositories {
    maven { url = "https://crzd.me/files/maven/" }
    maven { url = "https://dl.bintray.com/squiddev/maven" }
    maven { url = "https://repo.eclipse.org/content/groups/releases/" }
}

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"

    compile "dan200.computercraft:ComputerCraft:1.80pr0-build0"
    compile "org.squiddev:CCTweaks:1.10.2-1.5.0-pr0:dev"

    shadow 'org.eclipse.jgit:org.eclipse.jgit:4.5.0.201609210915-r'

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

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

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

}

/*jar {
    configurations.shade.each { dep ->
        from(project.zipTree(dep)){
            exclude 'META-INF', 'META-INF/**'
        }
    }
}*/

shadowJar {
    baseName = 'shadow'
    classifier = null
    version = null
    configurations = [project.configurations.compile]
}

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

build.dependsOn shadowJar

 

 

Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

I did not say to not put it in dependencies. I said to not use a separate config.

Ah, so also use compile.  Tried that, it worked (well, compiled), but ended up with the same results as using "shade" : log4j crashes immediately, and nothing about my mod works.  Attempting to use any method I add results in an error referring to log4j.

Spoiler

2017-06-16 11:37:28,362 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
  <log4j:Event logger="LaunchWrapper" timestamp="1497631048388" level="INFO" thread="main">
    <log4j:Message><![CDATA[Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker]]></log4j:Message>
  </log4j:Event>
expected <
2017-06-16 11:37:31,559 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-06-16 11:37:31,560 WARN Caught Exception while in Loader.getResource. This may be innocuous. java.lang.IllegalArgumentException: name
	at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:494)
	at sun.misc.URLClassPath.findResource(URLClassPath.java:176)
	at java.net.URLClassLoader$2.run(URLClassLoader.java:557)
	at java.net.URLClassLoader$2.run(URLClassLoader.java:555)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findResource(URLClassLoader.java:554)
	at java.lang.ClassLoader.getResource(ClassLoader.java:1093)
	at org.apache.logging.log4j.core.helpers.Loader.getResource(Loader.java:98)
	at org.apache.logging.log4j.core.config.ConfigurationFactory.getInputFromResource(ConfigurationFactory.java:300)
	at org.apache.logging.log4j.core.config.ConfigurationFactory.getInputFromString(ConfigurationFactory.java:280)
	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:380)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:377)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:149)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:85)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:387)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:322)
	at net.minecraft.client.Minecraft.<clinit>(Minecraft.java:208)
	at net.minecraft.client.main.Main.main(SourceFile:39)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

2017-06-16 11:37:31,575 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
  <log4j:Event logger="net.minecraft.client.Minecraft" timestamp="1497631051742" level="INFO" thread="Client thread">
    <log4j:Message><![CDATA[Setting user: KingofGamesYami]]></log4j:Message>
  </log4j:Event>
expected <
MultiModel minecraft:builtin/missing is empty (no base model or parts were provided/resolved)

 

 

Link to comment
Share on other sites

Spoiler

buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
    }
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.

version = "2.0"
group= "org.kingofgamesyami.ccgit" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ccgit"

sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly.
compileJava {
    sourceCompatibility = targetCompatibility = "1.6"
}

minecraft {
    version = "1.10.2-12.18.3.2316"
    runDir = "run"
    
    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161111"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    //something that might help?
}

repositories {
    maven { url = "https://crzd.me/files/maven/" }
    maven { url = "https://dl.bintray.com/squiddev/maven" }
    maven { url = "https://repo.eclipse.org/content/groups/releases/" }
}

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"

    compile "dan200.computercraft:ComputerCraft:1.80pr0-build0"
    compile "org.squiddev:CCTweaks:1.10.2-1.5.0-pr0:dev"

    compile 'org.eclipse.jgit:org.eclipse.jgit:4.5.0.201609210915-r'

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

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

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

}

/*
jar {
    configurations.compile.each { dep ->
        from(project.zipTree( dep )){
            exclude 'META-INF', 'META-INF/**'
        }
    }
}
*/

shadowJar {
    dependencies {
        exclude( dependency( 'dan200.computercraft:ComputerCraft:1.80pr0-build0') )
        exclude( dependency( 'org.squiddev:CCTweaks:1.10.2-1.5.0-pr0:dev' ) )
    }
}

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

build.dependsOn shadowJar

 

 

Link to comment
Share on other sites

Done!  Apologies if anything is missing, I tired to exclude anything which wouldn't be needed.

 

Edit: Almost forgot, you're probably not familiar with ComputerCraft.  Once you have the game running, get an advanced computer, place it, right click to open the GUI.  Type in "lua" to enter the lua console.  Type "ccgit.init( "/test" )" to try to create a git repo.  It will show an error message.  If it doesn't, I want to know why it works for you and not me XD.

Edited by KingofGamesYami
Link to comment
Share on other sites

7 minutes ago, diesieben07 said:

The ComputerCraft dependency cannot be resolved.

Ah, the custom build server is down.  It was run by a member of the community, looks like he moved it or something. I'll PM some people about it.  You can get it here for 1.11.2 (which my mod is compatible with), though you'll need a newer version of CCTweaks for the mods folder (not to compile against). moved to here.

Edited by KingofGamesYami
Link to comment
Share on other sites

Reproduction Steps:

1. Clone repo

2. gradlew build

3. Add ccgit-2.0-all to mods folder with CCTweaks and ComputerCraft.

4. Launch game using minecraft launcher

5. Place an advanced computer

6. Open Lua console. (type lua)

7. Attempt to create repository (type ccgit.init( 'test' ))

8. Observe Java Exception Thrown: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

9. Attempt to open repository (type ccgit.open( 'test'))

10. Observe Java Exception Thrown: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jgit.internal.storage.file.FileRepository

 

 

Edited by KingofGamesYami
Link was broken
Link to comment
Share on other sites

  • 1 year later...

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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.