This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
209 lines (171 loc) · 6.21 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
@file:Suppress("SpellCheckingInspection", "UnstableApiUsage")
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm")
kotlin("plugin.serialization") version "2.0.20"
id("fabric-loom") version "1.7-SNAPSHOT"
id("me.modmuss50.mod-publish-plugin") version "0.5.+"
id("com.google.devtools.ksp")
`maven-publish`
}
val beta: Int = 32 // Pattern is '1.0.0-beta1-1.20.6-pre.2'; when beta == 0 beta is null
val featureVersion = "1.0.0${if (beta != 0) "-beta$beta" else ""}"
val mcVersion = property("mcVersion")!!.toString()
val mcVersionRange = property("mcVersionRange")!!.toString()
val awVersion = if (stonecutter.compare(mcVersion, "1.21") >= 0) "1.21" else "1.20"
version = "$featureVersion-$mcVersion"
group = "dev.nyon"
val authors = listOf("btwonion")
val githubRepo = "btwonion/skylper"
base {
archivesName.set("skylper")
}
loom {
if (stonecutter.current.isActive) {
runConfigs.all {
ideConfigGenerated(true)
runDir("../../run")
}
}
mixin { useLegacyMixinAp = false }
accessWidenerPath = rootProject.file("src/main/resources/aw/$awVersion.accesswidener")
}
repositories {
mavenCentral()
maven("https://maven.terraformersmc.com")
maven("https://maven.quiltmc.org/repository/release/")
maven("https://repo.nyon.dev/releases")
maven("https://maven.isxander.dev/releases")
exclusiveContent {
forRepository {
maven("https://api.modrinth.com/maven")
}
filter {
includeGroup("maven.modrinth")
}
}
}
val transitiveInclude: Configuration by configurations.creating {
exclude(group = "org.jetbrains.kotlinx")
exclude(group = "org.jetbrains.kotlin")
exclude(group = "com.mojang")
}
dependencies {
minecraft("com.mojang:minecraft:$mcVersion")
mappings(loom.layered {
val quiltMappings: String = property("deps.quiltmappings").toString()
if (quiltMappings.isNotEmpty()) mappings("org.quiltmc:quilt-mappings:$quiltMappings:intermediary-v2")
officialMojangMappings()
})
implementation("org.vineflower:vineflower:1.10.1")
modImplementation("net.fabricmc:fabric-loader:0.16.0")
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")!!}")
modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0")
modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")!!}")
modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")!!}")
val runtimeTestMods = property("runtimeTestMods")!!.toString().split(',').map { it.split(':') }
runtimeTestMods.forEach { (projectId, versionId) ->
modRuntimeOnly("maven.modrinth:$projectId:$versionId")
}
include(modImplementation("dev.nyon:konfig:2.0.2-1.20.4")!!)
compileOnly(ksp(project(":annotation-processor"))!!)
val ktorVersion = "2.3.0"
include(implementation("io.ktor:ktor-client-core:$ktorVersion")!!)
transitiveInclude(implementation("io.ktor:ktor-client-cio:$ktorVersion")!!)
transitiveInclude.resolvedConfiguration.resolvedArtifacts.forEach {
include(it.moduleVersion.id.toString())
}
}
val javaVersion = property("javaVer")!!.toString()
tasks {
processResources {
val modId = "skylper"
val modName = "skylper"
val modDescription = "Utility mod for Hypixel Skyblock"
val props = mapOf(
"id" to modId,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubRepo,
"mc" to mcVersionRange,
"aw" to awVersion
)
props.forEach(inputs::property)
filesMatching("fabric.mod.json") {
expand(props)
}
}
register("releaseMod") {
group = "publishing"
dependsOn("publishMods")
dependsOn("publish")
}
withType<JavaCompile> {
options.release = javaVersion.toInt()
}
withType<KotlinCompile> {
inputs.files(
(project.file("../../src/main/kotlin/dev/nyon/skylper/extensions/event/").listFiles()?.map { it.path }
?: emptyList()).toTypedArray())
compilerOptions {
jvmTarget = JvmTarget.fromTarget(javaVersion)
}
}
}
val changelogText = buildString {
append("# v${project.version}\n")
if (beta != 0) append("### As this is still a beta version, this version can contain bugs. Feel free to report ANY misbehaviours and errors!\n")
rootProject.file("${if (beta != 0) "beta-" else ""}changelog.md").readText().also { append(it) }
}
val supportedMcVersions: List<String> =
property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty)
publishMods {
displayName = "v${project.version}"
file = tasks.remapJar.get().archiveFile
changelog = changelogText
type = if (beta != 0) BETA else STABLE
modLoaders.addAll("fabric", "quilt")
modrinth {
projectId = "MXwU9ODv"
accessToken = providers.environmentVariable("MODRINTH_API_KEY")
minecraftVersions.addAll(supportedMcVersions)
requires { slug = "fabric-api" }
requires { slug = "yacl" }
requires { slug = "fabric-language-kotlin" }
optional { slug = "modmenu" }
}
github {
repository = githubRepo
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = "master"
}
}
publishing {
repositories {
maven {
name = "nyon"
url = uri("https://repo.nyon.dev/releases")
credentials {
username = providers.environmentVariable("NYON_USERNAME").orNull
password = providers.environmentVariable("NYON_PASSWORD").orNull
}
}
}
publications {
create<MavenPublication>("maven") {
groupId = "dev.nyon"
artifactId = "skylper"
version = project.version.toString()
from(components["java"])
}
}
}
java {
withSourcesJar()
javaVersion.toInt().let { JavaVersion.values()[it - 1] }.let {
sourceCompatibility = it
targetCompatibility = it
}
}