-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
113 lines (100 loc) · 3.31 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
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
plugins {
java
`java-library`
alias(libs.plugins.loom)
`maven-publish`
alias(libs.plugins.spotless)
alias(libs.plugins.minotaur)
}
val modrinthId: String by project
val minecraftCompatible: String by project
val project_version: 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: String = "$project_version+mc.${libs.versions.minecraft.version.get()}"
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
withSourcesJar()
withJavadocJar()
}
repositories {
mavenCentral()
maven("Nexus Repository OSS") {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
maven("Modrinth") {
url = uri("https://api.modrinth.com/maven")
}
}
dependencies {
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn) { classifier("v2") })
modImplementation(libs.quilt.loader)
modRuntimeOnly(libs.bundles.mod.runtime)
}
spotless {
val licenseHeader = rootDir.resolve(".internal/license-header.java")
java {
importOrderFile(rootDir.resolve(".internal/spotless.importorder"))
// If the spotless config doesn't exist, this will fall back to the eclipse default.
val eclipse = eclipse()
val eclipseConfig = rootDir.resolve(".internal/spotless.xml")
if (eclipseConfig.exists()) eclipse.configFile(eclipseConfig)
// If the license header doesn't exist, it'll simply not be applied.
if (licenseHeader.exists()) licenseHeaderFile(licenseHeader)
}
kotlinGradle {
target("*.gradle.kts")
if (licenseHeader.exists()) licenseHeaderFile(licenseHeader, "(import|plugins|rootProject)")
}
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.isDeprecation = true
options.isWarnings = true
}
processResources {
val map =
mapOf(
"id" to project.name,
"java" to java.targetCompatibility.majorVersion,
"version" to project.version,
"project_version" to project_version,
"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 project_version -> "alpha"
!isRelease || '-' in project_version -> "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/drip/releases/tag/${URLEncoder.encode(ref.substring(10), StandardCharsets.UTF_8)}"
else "No changelog is available. Perhaps poke at https://github.com/Modflower/drip for a changelog?"
)
uploadFile.set(tasks.remapJar.get())
gameVersions.set(minecraftCompatible.split(","))
loaders.addAll("fabric", "quilt")
}