-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
106 lines (88 loc) · 3.12 KB
/
build.gradle
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
plugins {
id "fabric-loom" version "1.4-SNAPSHOT"
id "org.ajoberstar.grgit" version "4.1.0"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
String minecraftDependencyVersion = project.minecraft_version.split(/[+ -]/)[0]
group = project.maven_group
version = "${project.mod_version}${getVersionMetadata()}"
archivesBaseName = "${project.archives_base_name}-mc${minecraftDependencyVersion}"
repositories {
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}
maven {
name = "Cloth Config"
url = "https://maven.shedaniel.me/"
content {
includeGroup "me.shedaniel.cloth"
}
}
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
modImplementation "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}"
modCompileOnly "maven.modrinth:inventory-profiles-next:fabric-${project.ipn_version}"
}
processResources {
def fabricModProperties = [
"version": version,
"minecraft": ">=${minecraftDependencyVersion.replaceFirst(/^(\d+\.\d+)(\.\d+|)$/, '$1')}",
"cloth_config": ">=${project.cloth_version}",
"inventory_profiles_next": ">=${project.ipn_version}",
"modmenu": ">=${project.modmenu_version}",
]
filesMatching("fabric.mod.json") {
expand fabricModProperties
}
}
tasks.withType(JavaCompile).configureEach {
// Ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly.
// If Javadoc is generated, this must be specified in that task too.
// See http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
it.options.encoding = "UTF-8"
it.options.release.set(17)
}
java {
withSourcesJar()
}
jar {
from "LICENSE.md"
}
@SuppressWarnings("GrMethodMayBeStatic") // It cannot
String getVersionMetadata() {
// Release builds don't require additional metadata
String ref = System.getenv("GITHUB_REF")
if (ref != null && ref.startsWith("refs/tags/")) {
return ""
}
// GitHub CI builds only
String build_id = System.getenv("GITHUB_RUN_NUMBER")
if (build_id != null && build_id.length() != 0) {
return "+build.${build_id}"
}
if (grgit != null && grgit.head() != null) {
def id = grgit.head().abbreviatedId
// Flag the build if the build tree is not clean
if (!grgit.status().clean) {
id += "-dirty"
}
return "+rev.${id}"
}
// No tracking information could be found about the build
return "+unknown"
}