aboutsummaryrefslogtreecommitdiff
path: root/ingame/build.gradle.kts
blob: 4c9e14f0a746b090b6c751941a408d71b8f35cec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import net.minecraftforge.gradle.user.ReobfMappingType

plugins {
    java
    kotlin("jvm") version "1.6.10"
    id("net.minecraftforge.gradle.forge") version "6f5327738df"
    id("com.github.johnrengelman.shadow") version "6.1.0"
    id("org.spongepowered.mixin") version "d75e32e"
}

group = "moe.nea89.sbdatacollection"
version = "2.1"

// Toolchains:

java {
    // Forge Gradle currently prevents using the toolchain: toolchain.languageVersion.set(JavaLanguageVersion.of(8))
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

minecraft {
    version = "1.8.9-11.15.1.2318-1.8.9"
    runDir = "run"
    mappings = "stable_22"
    clientJvmArgs.addAll(
        listOf(
            "-Dmixin.debug=true",
            "-Dasmhelper.verbose=true"
        )
    )
    clientRunArgs.addAll(
        listOf(
            "--tweakClass org.spongepowered.asm.launch.MixinTweaker",
            "--mixin mixins.sbdata.json"
        )
    )
}

mixin {
    add(sourceSets.main.get(), "mixins.sbdata.refmap.json")
}

sourceSets {
    main {
        output.setResourcesDir(file("$buildDir/classes/kotlin/main"))
    }
}

// Dependencies:

repositories {
    mavenCentral()
    flatDir { dirs("deps/") }
    maven("https://repo.spongepowered.org/maven/")
}

dependencies {
    implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT")
    annotationProcessor("org.spongepowered:mixin:0.7.11-SNAPSHOT")
}


// Tasks:

tasks.withType(JavaCompile::class) {
    options.encoding = "UTF-8"
}

tasks.withType(Jar::class) {
    archiveBaseName.set("sbdata")
    manifest.attributes.run {
        this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
        this["MixinConfigs"] = "mixins.sbdata.json"
        this["FMLCorePluginContainsFMLMod"] = "true"
        this["ForceLoadAsMod"] = "true"
        this["FMLAT"] = "sbdata_at.cfg"
    }
}

tasks.shadowJar {
    archiveClassifier.set("uberfatshadowfullalldeps")
    fun relocate(name: String) = relocate(name, "moe.nea89.sbdata.deps.$name")
}

tasks.build.get().dependsOn(tasks.shadowJar)

reobf {
    create("shadowJar") {
        mappingType = ReobfMappingType.SEARGE
    }
}

tasks.processResources {
    from(sourceSets.main.get().resources.srcDirs)
    filesMatching("mcmod.info") {
        expand(
            "modversion" to project.version,
            "mcversion" to minecraft.version
        )
    }
    rename("(.+_at.cfg)".toPattern(), "META-INF/$1")
}