-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
110 lines (89 loc) · 2.55 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
plugins {
id("fabric-loom") version "0.10.+"
id("org.ajoberstar.grgit") version "4.1.1"
id("maven-publish")
}
val modId: String by project
val modName: String by project
val modVersion: String by project
val mavenGroup: String by project
base.archivesName.set(modId)
// Minecraft version has space after for some reason
version = "$modVersion-${libs.versions.minecraft.get()}${getVersionMetadata()}".replace(" ", "")
group = mavenGroup
repositories {
}
dependencies {
// To change the versions see the libs.versions.toml
// Fabric
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn.mappings) { classifier("v2") })
modImplementation(libs.fabric.loader)
// Fabric API
modImplementation(libs.fabric.api)
}
tasks {
processResources {
inputs.property("id", modId)
inputs.property("name", modName)
inputs.property("version", modVersion)
filesMatching("fabric.mod.json") {
expand(
mapOf(
"id" to modId,
"version" to modVersion,
"name" to modName,
"fabricApi" to libs.versions.fabric.api.get(),
)
)
}
}
jar {
from("LICENSE")
}
java {
withSourcesJar()
}
}
// configure the maven publication
publishing {
publications {
create<MavenPublication>("mavenJava") {
// add all the jars that should be included when publishing to maven
artifact(tasks.jar) {
builtBy(tasks.remapJar)
}
artifact(tasks.getByName("sourcesJar")) {
builtBy(tasks.remapSourcesJar)
}
}
}
// select the repositories you want to publish to
repositories {
// mavenLocal()
}
}
fun getVersionMetadata(): String {
if (System.getenv("GITHUB_WORKFLOW") == "Release") return ""
val buildId = System.getenv("GITHUB_RUN_NUMBER")
// CI builds only
if (buildId != null) {
return "+build.$buildId"
}
try {
val grgit = org.ajoberstar.grgit.Grgit.open()
if (grgit != null) {
val head = grgit.head()
var id = head.abbreviatedId
// Flag the build if the build tree is not clean
if (!grgit.status().isClean) {
id += "-dirty"
}
return "+rev.$id"
}
} catch (e: java.lang.IllegalStateException) {
// No git repo
}
// No tracking information could be found about the build
return "+unknown"
}