1

How do you declare a local dependency for gradle 4.10.3 to not use the github project and use your own custom build of the project? Open source project I'm trying to compile https://github.com/kami-blue/client

enter image description here

My build is at /Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar

I've tried changing the file path to it and commenting out the two compile commands but that didn't work.

//compile 'com.github.cabaletta:baritone:1.2.14'
//compile 'cabaletta:baritone-api:1.2'
include(dependency('/Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar'))

Using these either of these two methods do not work either:

implementation files('/Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar')
compile fileTree(dir: '/Users/macbook/Desktop/baritone-master/dist', include: ['*.jar'])

enter image description here enter image description here

build.gradle file:

buildscript {
    repositories {
        jcenter()
        maven {
            name = 'forge'
            url = 'http://files.minecraftforge.net/maven'
        }
        maven {
            name = 'SpongePowered'
            url = 'http://repo.spongepowered.org/maven'
        }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
        classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
        classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
        classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: "${kotlin_version}"    }
}

apply plugin: 'kotlin'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'com.github.johnrengelman.shadow'

version project.modVersion
group project.modGroup // http://maven.apache.org/guides/mini/guide-naming-conventions.html

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

sourceCompatibility = targetCompatibility = '1.8'
compileJava {
    sourceCompatibility = targetCompatibility = '1.8'
}

minecraft {
    version = project.forgeVersion
    runDir = 'run'
    mappings = project.mcpVersion
    coreMod = 'me.zeroeightsix.kami.mixin.MixinLoaderForge'
    makeObfSourceJar = false
}

repositories {
    maven {
        name = 'spongepowered-repo'
        url = 'http://repo.spongepowered.org/maven/'
    }
    maven {
        name = 'impactdevelopment-repo'
        url = 'https://impactdevelopment.github.io/maven/'
    }
    maven {
        name = 'swt-repo'
        url = "http://maven-eclipse.github.io/maven"
    }
    maven {
        name = "jitpack.io"
        url = "https://jitpack.io"
    }
    maven {
        name = "forgelin-repo"
        url "http://maven.shadowfacts.net/"
    }
    mavenCentral()
    jcenter()
}

dependencies {
    // mixin needs to be distributed with the mod, very important
    compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") { // do NOT update this to 8.0 or above, it breaks compatibility with future client
        exclude module: 'launchwrapper'
        exclude module: 'guava'
        exclude module: 'gson'
        exclude module: 'commons-io'
        exclude module: 'log4j-core' // we want to exclude this as well because 0.7.11 includes it too new for MC
    }
    compile "com.github.ZeroMemes:Alpine:1.7"
    compile group: 'net.jodah', name: 'typetools', version: '0.6.2'
    compile group: 'org.yaml', name: 'snakeyaml', version: '1.26'
    compile(group: 'org.reflections', name: 'reflections', version: '0.9.12') {
        exclude group: 'com.google.guava', module: 'guava'
    }
    compile 'club.minnced:java-discord-rpc:2.0.2'
    compile 'com.github.MrPowerGamerBR:TemmieWebhook:-SNAPSHOT'
    compile 'com.github.kevinsawicki:http-request:http-request-6.0'
    compile 'com.github.cabaletta:baritone:1.2.14'
    compile 'cabaletta:baritone-api:1.2'
    compile group: "net.shadowfacts", name: "Forgelin", version: "1.8.4"
    compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: kotlin_version
    compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk7", version: kotlin_version
    compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: kotlin_version
    compile group: "org.jetbrains.kotlin", name: "kotlin-reflect", version: kotlin_version
    compile group: "org.jetbrains", name: "annotations", version: annotations_version
    compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-core", version: coroutines_version
    compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-jdk8", version: coroutines_version
}

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

    // move _at.cfg into META-INF
    rename '(.+_at.cfg)', 'META-INF/$1'
}

shadowJar {
    dependencies {
        include(dependency('org.spongepowered:mixin'))
        include(dependency('com.github.ZeroMemes:Alpine'))
        include(dependency('club.minnced:java-discord-rpc'))
        include(dependency('net.jodah:typetools'))
        include(dependency('org.yaml:snakeyaml'))
        include(dependency('org.reflections:reflections'))
        include(dependency('org.javassist:javassist'))
        include(dependency('com.github.MrPowerGamerBR:TemmieWebhook'))
        include(dependency('com.github.kevinsawicki:http-request'))
        include(dependency('cabaletta:baritone-api'))
        include(dependency("org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"))
        include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"))
        include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"))
        include(dependency("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"))
        include(dependency("org.jetbrains:annotations:${annotations_version}"))
        include(dependency("org.jetbrains.kotlinx:kotlinx-coroutines-core:${coroutines_version}"))
        include(dependency("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${coroutines_version}"))
        include(dependency('net.shadowfacts:Forgelin'))
    }
    exclude 'dummyThing' // can someone explain why this is here
    classifier = 'release'
}

mixin {
    defaultObfuscationEnv searge
    add sourceSets.main, 'mixins.kami.refmap.json'
}

reobf {
    shadowJar {
        mappingType = 'SEARGE'
        classpath = sourceSets.main.compileClasspath
    }
}

// Don't put baritone mixin here please c:
jar {
    manifest {
        attributes(
                'MixinConfigs': 'mixins.kami.json',
                'tweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
                'TweakOrder': 0,
                'FMLCorePluginContainsFMLMod': 'true',
                'FMLCorePlugin': 'me.zeroeightsix.kami.mixin.MixinLoaderForge',
                'ForceLoadAsMod': 'true',
                'FMLAT': 'kami_at.cfg'
        )
    }
}

build.dependsOn(shadowJar)
AndrewFerrara
  • 2,383
  • 8
  • 30
  • 45
  • If you really want to do that, have a look at this [question](https://stackoverflow.com/questions/20700053/how-to-add-local-jar-file-dependency-to-build-gradle-file) – Patrick Santana Jun 03 '20 at 08:35

1 Answers1

2

Please try this. Should fix your problem.

In this case gradle will try to use a relative path for a local jar dependency.

Read those documentaries for more information

dependencies {
    implementation files('/Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar') 
}

Additionally you can add all jars in X directory.

dependencies {
    compile fileTree(dir: 'yourDirection', include: ['*.jar'])
}
Dogus
  • 61
  • 4
  • Could not find method implementation() for arguments [file collection] on object of type... – AndrewFerrara Jun 03 '20 at 09:06
  • Could not find method compile() for arguments [directory '/Users.... – AndrewFerrara Jun 03 '20 at 09:07
  • I guess that implementation() is "outdated". So you need to use copile instead of the word implementation. Furthermore I think you edit the wrong build.gradle file. You can't use compile in the top-level file. Use the module/build.gradle. || \app\build.gradle is specific for app module. || \build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules. – Dogus Jun 03 '20 at 09:09
  • Maybe this will help. https://stackoverflow.com/questions/46049022/could-not-find-method-compile – Dogus Jun 03 '20 at 09:11
  • I added more screenshots of the errors with your approach to the question. – AndrewFerrara Jun 03 '20 at 17:18