buildscript {
    repositories {
        jcenter()
        maven { url "http://files.minecraftforge.net/maven" }
        maven { url "http://repo.spongepowered.org/maven" }
    }
    dependencies {
        classpath "com.github.jengelman.gradle.plugins:shadow:2.0.4"
        classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
        classpath "org.spongepowered:mixingradle:0.6-SNAPSHOT"
    }
}

apply plugin: "java"
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "org.spongepowered.mixin"

repositories {
    maven { url "http://repo.spongepowered.org/maven" }
    maven { url "http://chickenbones.net/maven/" }
    maven { url "http://www.dimdev.org/maven" }
    maven { url "http://maven.tterrag.com/" }
    ivy {
        url "https://google.com/404"
        ivyPattern("https://google.com/404") // Workaround for https://github.com/gradle/gradle/issues/4107
        artifactPattern("https://media.forgecdn.net/files/[organisation]/[module]/[revision].[ext]")
    }
}

dependencies {
    implementation("org.dimdev:mixin:0.7.11-SNAPSHOT") {
        exclude module: "asm-commons"
        exclude module: "asm-tree"
        exclude module: "launchwrapper"
        exclude module: "guava"
        exclude module: "log4j-core"
        exclude module: "gson"
        exclude module: "commons-io"
    }
    compileOnly "2535:884:Chisel-MC1.12.2-0.2.0.31@jar"
    compileOnly "2530:225:OpenBlocks-1.12.2-1.7.6@jar"
    compileOnly "2525:230:OpenModsLib-1.12.2-0.11.5@jar"
    compileOnly "2568:0:TConstruct-1.12.2-2.10.1.84@jar"
    compileOnly "2568:0:TConstruct-1.12.2-2.10.1.84@jar"
    compileOnly "2511:625:Avaritia-1.12-3.2.0.13-universal@jar"
    compileOnly "codechicken:CodeChickenLib:1.12.2-3.1.9.344:deobf"
    compileOnly "2482:584:CustomMainMenu-MC1.12.2-2.0.8@jar"
    compileOnly "team.chisel.ctm:CTM:MC1.12-0.2.3.12"
}

def travisBuildNumber = System.getenv("TRAVIS_BUILD_NUMBER")
def versionSuffix = travisBuildNumber != null ? travisBuildNumber : "SNAPSHOT"

version "1.1.1-$versionSuffix"
group "org.dimdev.vanillafix"
archivesBaseName = "VanillaFix"

sourceCompatibility = 1.8
targetCompatibility = 1.8

sourceSets {
    main
}

minecraft {
    version "1.12.2-14.23.5.2768"
    runDir "run"
    mappings "stable_39"
    makeObfSourceJar false

    def args = [
            "-Dfml.coreMods.load=org.dimdev.vanillafix.VanillaFixLoadingPlugin",
            "-Dmixin.hotSwap=true",
            "-Dmixin.checks.interfaces=true",
            "-Dmixin.debug.export=true"
    ]
    clientJvmArgs.addAll(args)
    serverJvmArgs.addAll(args)
}

mixin {
    add sourceSets.main, "mixins.vanillafix.refmap.json"
}

reobf {
    shadowJar {
        mappingType = "SEARGE"
    }
}

processResources {
    filesMatching("mcmod.info") {
        expand "version": project.version, "mcversion": project.minecraft.version
    }

    // Re-run this task when these change
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version
}

jar {
    classifier "thin"
    manifest.attributes(
            "FMLCorePlugin": "org.dimdev.vanillafix.VanillaFixLoadingPlugin",
            "FMLCorePluginContainsFMLMod": "true",
            "FMLAT": "vanillafix_at.cfg"
    )
}

shadowJar {
    classifier ""
    exclude "LICENSE.txt", "dummyThing"
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier "sources"
    from sourceSets.main.allSource
}

artifacts {
    archives jar
    archives shadowJar
    archives sourcesJar
}

// These are broken
runClient.group "other"
runServer.group "other"
