forked from devOS-Sanity-Edition/fabric-nautical-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
133 lines (110 loc) · 3.51 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
plugins {
kotlin("jvm") version "2.0.20"
`maven-publish`
java
alias(libs.plugins.grgit)
alias(libs.plugins.fabric.loom)
}
val archivesBaseName = "${project.property("archives_base_name").toString()}+mc${libs.versions.minecraft.get()}"
version = getModVersion()
group = project.property("maven_group")!!
repositories {
maven("https://api.modrinth.com/maven")
maven("https://maven.terraformersmc.com/")
maven("https://maven.parchmentmc.org")
maven("https://mvn.devos.one/snapshots")
maven("https://maven.quiltmc.org/repository/release/")
}
//All dependencies and their versions are in ./gradle/libs.versions.toml
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.21:2024.07.28@zip")
// mappings("${libs.quilt.mappings.get()}:intermediary-v2") // if you wanna deal with it be my guest, im not - asoji
})
//Fabric
modImplementation(libs.fabric.loader)
modImplementation(libs.fabric.api)
modImplementation(libs.fabric.language.kotlin)
//Mods
modImplementation(libs.bundles.dependencies)
modLocalRuntime(libs.bundles.dev.mods)
include(modImplementation("gay.asoji:fmw:1.0.0+build.8")!!) // just to avoid the basic long metadata calls
}
// Write the version to the fabric.mod.json
tasks.processResources {
inputs.property("version", project.version)
filesMatching("fabric.mod.json") {
expand(mutableMapOf("version" to project.version))
}
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(21)
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
}
// This will attempt to publish the mod to the devOS Maven, otherwise it will build the mod locally
// This is auto run by GitHub Actions
task("buildOrPublish") {
group = "build"
var mavenUser = System.getenv().get("MAVEN_USER")
if (!mavenUser.isNullOrEmpty()) {
dependsOn(tasks.getByName("publish"))
println("prepared for publish")
} else {
dependsOn(tasks.getByName("build"))
println("prepared for build")
}
}
// TODO: Uncomment for a non template mod!
publishing {
// publications {
// create<MavenPublication>("mavenJava") {
// groupId = project.property("maven_group").toString()
// artifactId = project.property("archives_base_name").toString()
// version = getModVersion()
//
// from(components.get("java"))
// }
// }
//
// repositories {
// maven {
// url = uri("https://mvn.devos.one/${System.getenv()["PUBLISH_SUFFIX"]}/")
// credentials {
// username = System.getenv()["MAVEN_USER"]
// password = System.getenv()["MAVEN_PASS"]
// }
// }
// }
}
fun getModVersion(): String {
val modVersion = project.property("mod_version")
val buildId = System.getenv("GITHUB_RUN_NUMBER")
// CI builds only
if (buildId != null) {
return "${modVersion}+build.${buildId}"
}
// If a git repo can't be found, grgit won't work, this non-null check exists so you don't run grgit stuff without a git repo
if (grgitService.service.get().grgit.head() != null) {
var id = grgitService.service.get().grgit.head().abbreviatedId ?: "NO-COMMIT-HASH"
// Flag the build if the build tree is not clean
// (aka you have uncommitted changes)
if (!grgitService.service.get().grgit.status().isClean()) {
id += "-dirty"
}
// ex: 1.0.0+rev.91949fa or 1.0.0+rev.91949fa-dirty
return "${modVersion}+rev.${id}"
}
// No tracking information could be found about the build
return "${modVersion}+unknown"
}