aboutsummaryrefslogtreecommitdiff
path: root/build.gradle.kts
blob: af7feabe7bbc0bc75a2419d8686964be683d05ec (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    java
    `maven-publish`
    kotlin("jvm") version "1.7.10"
    kotlin("plugin.serialization") version "1.7.10"
    id("dev.architectury.loom") version "0.12.0.+"
    id("com.github.johnrengelman.shadow") version "7.1.2"
    id("moe.nea.licenseextractificator") version "0.0.1"
    id("com.github.eutro.hierarchical-lang") version "1.1.3"
}

loom {
    accessWidenerPath.set(project.file("src/main/resources/notenoughupdates.accesswidener"))
    runConfigs {
        removeIf { it.name != "client" }
    }
    launches {
        named("client") {
            property("devauth.enabled", "true")
            property("fabric.log.level", "info")
            property("notenoughupdates.debug", "true")
        }
    }
}

repositories {
    maven("https://maven.terraformersmc.com/releases/")
    maven("https://maven.shedaniel.me")
    maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
    maven("https://api.modrinth.com/maven") {
        content {
            includeGroup("maven.modrinth")
        }
    }
    maven("https://server.bbkr.space/artifactory/libs-release")
    mavenLocal()
}

val shadowMe by configurations.creating {
    configurations.implementation.get().extendsFrom(this)
}

val transInclude by configurations.creating {
    exclude(group = "com.mojang")
    exclude(group = "org.jetbrains.kotlin")
    exclude(group = "org.jetbrains.kotlinx")
    isTransitive = true
}

dependencies {
    // Minecraft dependencies
    "minecraft"("com.mojang:minecraft:${project.property("minecraft_version")}")
    "mappings"(loom.officialMojangMappings())

    // Fabric dependencies
    modImplementation("net.fabricmc:fabric-loader:${project.property("fabric_loader_version")}")
    modApi("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_api_version")}")
    modImplementation("net.fabricmc:fabric-language-kotlin:${project.property("fabric_kotlin_version")}")

    // Actual dependencies
    modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${rootProject.property("rei_version")}")
    shadowMe("io.github.moulberry:neurepoparser:0.0.1")
    shadowMe("com.github.hypfvieh:dbus-java-core:4.1.0")
    shadowMe("com.github.hypfvieh:dbus-java-transport-native-unixsocket:4.1.0")
    fun ktor(mod: String) = "io.ktor:ktor-$mod-jvm:${project.property("ktor_version")}"

    transInclude(implementation(ktor("client-core"))!!)
    transInclude(implementation(ktor("client-java"))!!)
    transInclude(implementation(ktor("serialization-kotlinx-json"))!!)
    transInclude(implementation(ktor("client-content-negotiation"))!!)
    modImplementation(include("io.github.cottonmc:LibGui:${project.property("libgui_version")}")!!)

    // Dev environment preinstalled mods
    modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:${project.property("rei_version")}")
    modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:${project.property("devauth_version")}")
    modRuntimeOnly("maven.modrinth:modmenu:${project.property("modmenu_version")}")

    transInclude.resolvedConfiguration.resolvedArtifacts.forEach {
        include(it.moduleVersion.id.toString())
    }
}


version = rootProject.property("mod_version").toString()
group = rootProject.property("maven_group").toString()

tasks.withType<JavaCompile> {
    options.encoding = "UTF-8"
    options.release.set(17)
}

java {
    withSourcesJar()
    toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

// could not set to 17, up to 16
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
    jvmTarget = "16"
}
val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
    jvmTarget = "16"
}

tasks.shadowJar {
    configurations = listOf(shadowMe)
    archiveClassifier.set("dev-thicc")
}

tasks.remapJar {
    injectAccessWidener.set(true)
    inputFile.set(tasks.shadowJar.flatMap { it.archiveFile })
    dependsOn(tasks.shadowJar)
    archiveClassifier.set("thicc")
}

tasks.processResources {
    filesMatching("**/fabric.mod.json") {
        expand(
            "version" to project.version
        )
    }
    filesMatching("**/lang/*.json") {
        flattenJson(this)
    }
}


tasks.create<moe.nea.licenseextractificator.LicenseDiscoveryTask>("license") {
    scanConfiguration(project.configurations.compileClasspath.get())
    outputFile.set(file("$buildDir/LICENSES.json"))
    licenseFormatter.set(moe.nea.licenseextractificator.JsonLicenseFormatter())
}