-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
169 lines (134 loc) · 4.96 KB
/
build.gradle.kts
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import com.modrinth.minotaur.TaskModrinthUpload
import com.modrinth.minotaur.request.VersionType
import org.jetbrains.changelog.date
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("fabric-loom")
val kotlinVersion: String by System.getProperties()
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
id("org.jetbrains.changelog") version "1.3.1"
id("com.modrinth.minotaur") version "1.2.1"
}
base {
val archivesBaseName: String by project
archivesName.set(archivesBaseName)
}
val env = System.getenv()
val minecraftVersion: String by project
val baseVersion = env["MOD_VERSION"] ?: "unreleased"
version = "$baseVersion+mc$minecraftVersion"
val mavenGroup: String by project
group = mavenGroup
changelog {
// cf. https://github.com/JetBrains/gradle-changelog-plugin
version.set(baseVersion)
header.set(provider { "[${version.get()}] - ${date()}" })
itemPrefix.set("*")
}
val versionChangelog by lazy { changelog.getOrNull(baseVersion) ?: changelog.getLatest() }
minecraft {}
repositories {
maven {
name = "CottonMC"
url = uri("https://server.bbkr.space/artifactory/libs-release")
}
maven {
name = "shedaniel"
url = uri("https://maven.shedaniel.me")
}
dependencies {
minecraft("com.mojang:minecraft:${minecraftVersion}")
val yarnMappings: String by project
mappings("net.fabricmc:yarn:$yarnMappings:v2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
val loaderVersion: String by project
modImplementation("net.fabricmc:fabric-loader:$loaderVersion")
val fabricVersion: String by project
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricVersion")
val fabricKotlinVersion: String by project
modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion")
val libGuiVersion: String by project
modImplementation("io.github.cottonmc:LibGui:$libGuiVersion")
include("io.github.cottonmc:LibGui:$libGuiVersion")
val roughlyEnoughItemsVersion: String by project
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:$roughlyEnoughItemsVersion")
modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:$roughlyEnoughItemsVersion")
modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:$roughlyEnoughItemsVersion")
val rebornEnergyVersion: String by project
modCompileOnly("teamreborn:energy:$rebornEnergyVersion")
}
}
loom {
// cf. https://github.com/FabricMC/fabric-loom
runs {
getByName("client").apply {
property("fabric.log.level", "info")
property("fabric.log.debug.level", "debug")
}
}
}
task<TaskModrinthUpload>("modrinth") {
// cf. https://github.com/modrinth/minotaur
group = "publishing"
onlyIf { "MODRINTH_TOKEN" in env.keys }
dependsOn("build")
val modrinthProjectId: String by project
projectId = modrinthProjectId
token = env["MODRINTH_TOKEN"]
uploadFile = tasks["remapJar"]
changelog = versionChangelog.toText()
versionNumber = version.toString()
versionName = baseVersion
val releaseType by lazy {
when {
"-alpha" in baseVersion -> VersionType.ALPHA
"-beta" in baseVersion -> VersionType.BETA
else -> VersionType.RELEASE
}
}
versionType = releaseType
addGameVersion(minecraftVersion)
addLoader("fabric")
}
tasks {
val javaVersion = JavaVersion.VERSION_17
withType<JavaCompile> {
options.encoding = "UTF-8"
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
options.release.set(javaVersion.toString().toInt())
}
withType<KotlinCompile> {
kotlinOptions { jvmTarget = javaVersion.toString() }
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}
jar {
val archivesBaseName: String by project
from("LICENSE") { rename { "${it}_${archivesBaseName}" } }
from("LICENSE.md") { rename { "${it}_${archivesBaseName}.md" } }
}
processResources {
inputs.property("version", project.version)
fun prop(name: String) = name to project.property(name)
filesMatching("fabric.mod.json") {
expand(
mapOf(
"version" to project.version,
prop("minecraftVersion"),
prop("loaderVersion"),
prop("fabricVersion"),
prop("fabricKotlinVersion"),
prop("libGuiVersion")
)
)
}
}
java {
toolchain { languageVersion.set(JavaLanguageVersion.of(javaVersion.toString())) }
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
withSourcesJar()
}
}