-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
181 lines (147 loc) · 5.17 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
@file:Suppress("SpellCheckingInspection", "UnstableApiUsage")
import net.fabricmc.loom.configuration.FabricApiExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "2.0.21"
kotlin("plugin.serialization") version "2.0.21"
id("fabric-loom") version "1.8-SNAPSHOT"
id("me.modmuss50.mod-publish-plugin") version "0.7.+"
`maven-publish`
}
val beta: Int? = null // Pattern is '1.0.0-beta1-1.20.6-pre.2'
val featureVersion = "3.2.0${if (beta != null) "-beta$beta" else ""}"
val mcVersion = property("mcVersion")!!.toString()
val mcVersionRange = property("mcVersionRange")!!.toString()
val mcVersionName = property("versionName")!!.toString()
version = "$featureVersion-$mcVersionName"
group = "dev.nyon"
val githubRepo = "btwonion/magnetic"
base {
archivesName.set(rootProject.name)
}
loom {
if (stonecutter.current.isActive) {
runConfigs.all {
ideConfigGenerated(true)
runDir("../../run")
}
}
accessWidenerPath = rootDir.resolve("src/main/resources/magnetic.accesswidener")
mixin { useLegacyMixinAp = false }
}
// Enable data generation for >1.20.6
val dataGen = stonecutter.eval(mcVersion, ">1.20.6")
if (dataGen) fabricApi(FabricApiExtension::configureDataGeneration)
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")
}
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.9")
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")!!}")
modImplementation("net.fabricmc:fabric-language-kotlin:1.12.3+kotlin.2.0.21")
modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")!!}")
modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")!!}")
include(modImplementation("dev.nyon:konfig:2.0.2-1.20.4")!!)
}
val javaVersion = if (stonecutter.eval(mcVersion, ">=1.20.6")) 21 else 17
tasks {
processResources {
val modId = "magnetic"
val modName = "magnetic"
val modDescription = "Magnetically moves items and experience into your inventory. Also known as telekinesis from Hypixel Skyblock."
val props = mapOf(
"id" to modId,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubRepo,
"mc" to mcVersionRange
)
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> {
compilerOptions {
jvmTarget = JvmTarget.fromTarget(javaVersion.toString())
}
}
build {
if (dataGen) dependsOn("runDatagen")
}
}
val changelogText = buildString {
append("# v${project.version}\n")
rootProject.file("changelog.md").readText().also(::append)
}
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 != null) BETA else STABLE
modLoaders.addAll("fabric", "quilt")
modrinth {
projectId = "LLfA8jAD"
accessToken = providers.environmentVariable("MODRINTH_API_KEY")
minecraftVersions.addAll(supportedMcVersions)
requires { slug = "fabric-api" }
requires { slug = "fabric-language-kotlin" }
requires { slug = "yacl" }
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 = "magnetic"
version = project.version.toString()
from(components["java"])
}
}
}
java {
withSourcesJar()
javaVersion.toInt().let { JavaVersion.values()[it - 1] }.let {
sourceCompatibility = it
targetCompatibility = it
}
}