-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
96 lines (86 loc) · 2.91 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
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
plugins {
java
`java-library`
alias(libs.plugins.loom)
alias(libs.plugins.spotless)
alias(libs.plugins.minotaur)
`maven-publish`
}
val minecraftVersion = libs.versions.minecraft.version.get()
val minecraftCompatible = libs.versions.minecraft.compatible.get()
val fabricApiVersion = libs.versions.fabric.api.get()
val projectVersion: String by project
val modrinthId: String by project
val isPublish = System.getenv("GITHUB_EVENT_NAME") == "release"
val isRelease = System.getenv("BUILD_RELEASE").toBoolean()
val isActions = System.getenv("GITHUB_ACTIONS").toBoolean()
val baseVersion = "$projectVersion+mc.$minecraftVersion"
version = when {
isRelease -> baseVersion
isActions -> "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
else -> "$baseVersion-build.local"
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn) { classifier("v2") })
modImplementation(libs.bundles.fabric)
include(modImplementation(fabricApi.module("fabric-lifecycle-events-v1", fabricApiVersion))!!)
include(modImplementation(fabricApi.module("fabric-api-base", fabricApiVersion))!!)
compileOnly(libs.bundles.compile)
}
spotless {
java {
importOrderFile(projectDir.resolve(".internal/spotless.importorder"))
eclipse().configFile(projectDir.resolve(".internal/spotless.xml"))
licenseHeaderFile(projectDir.resolve(".internal/license-header.java"))
}
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.isDeprecation = true
options.isWarnings = true
}
processResources {
val map = mapOf(
"version" to project.version,
"project_version" to projectVersion,
"minecraft_required" to libs.versions.minecraft.required.get()
)
inputs.properties(map)
filesMatching("fabric.mod.json") {
expand(map)
}
}
withType<Jar> {
from("LICENSE")
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(modrinthId)
versionType.set(
System.getenv("RELEASE_OVERRIDE") ?: when {
"alpha" in projectVersion -> "alpha"
!isRelease || '-' in projectVersion -> "beta"
else -> "release"
}
)
val ref = System.getenv("GITHUB_REF")
changelog.set(
System.getenv("CHANGELOG") ?: if (ref != null && ref.startsWith("refs/tags/")) "You may view the changelog at https://github.com/Modflower/data-driven-composter/releases/tag/${URLEncoder.encode(ref.substring(10), StandardCharsets.UTF_8)}"
else "No changelog is available. Perhaps poke at https://github.com/Modflower/data-driven-composter for a changelog?"
)
uploadFile.set(remapJar.get())
gameVersions.set(minecraftCompatible.split(","))
loaders.addAll("fabric", "quilt")
}
}