generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
192 lines (155 loc) · 5.19 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import java.net.URI
plugins {
id("idea")
id("maven-publish")
id("net.neoforged.moddev") version "1.0.15"
id("org.cadixdev.licenser") version "0.6.1"
}
val minecraftVersion: String by project
val neoForgeVersion: String by project
val testmod_id = "examplemod"
version = getVersionString()
group = "com.enderio"
repositories {
mavenLocal()
}
license {
setHeader(project.file("config/HEADER.txt"))
}
base {
archivesName.set("Regilite")
}
sourceSets {
main {
java {}
}
test {
java {
compileClasspath += main.get().output
runtimeClasspath += main.get().output
}
}
}
// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
neoForge {
// We currently only support NeoForge versions later than 21.0.x
// See https://projects.neoforged.net/neoforged/neoforge for the latest updates
version = neoForgeVersion
// Validate AT files and raise errors when they have invalid targets
// This option is false by default, but turning it on is recommended
validateAccessTransformers = true
addModdingDependenciesTo(sourceSets["test"])
runs {
create("client") {
client()
}
create("data") {
data()
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll(
"--mod", testmod_id,
"--all",
"--output", file("src/generated/resources/").getAbsolutePath(),
"--existing", file("src/test/resources/").getAbsolutePath())
}
create("server") {
server()
}
}
mods {
create("testproject") {
sourceSet(sourceSets["main"])
sourceSet(sourceSets["test"])
}
}
}
//sourceSets.test.runs {
// modIdentifier = "regilite"
//}
// Include resources generated by data generators.
sourceSets.test {
resources.srcDir("src/generated/resources")
}
java.withSourcesJar()
tasks.withType<Jar> {
manifest {
attributes(mapOf(
"FMLModType" to "GAMELIBRARY",
))
}
}
publishing {
publications {
create<MavenPublication>("regilite") {
groupId = "com.enderio"
artifactId = "regilite"
version = version
from(components["java"])
pom {
name.set("Regilite")
description.set("Regilite is a helper library that handles registries and basic data generation.")
url.set("https://github.com/Team-EnderIO/Regilite")
licenses {
license {
name.set("Unlicense")
url.set("https://github.com/Team-EnderIO/Regilite/blob/dev/${minecraftVersion}/LICENSE.txt")
}
}
scm {
url.set("https://github.com/Team-EnderIO/Regilite.git")
}
}
}
}
repositories {
if (System.getenv("RVR_MAVEN_USER") != null) {
maven {
name = "Rover656"
url = URI("https://maven.rover656.dev/releases")
credentials {
username = System.getenv("RVR_MAVEN_USER")
password = System.getenv("RVR_MAVEN_PASSWORD")
}
}
}
}
}
// ============
// Utilities
// ============
// * enderio-7.0.1-alpha.jar :: release version 7.0.1-alpha (discovered by git tag)
// * enderio-7.0.1.349-nightly :: nightly build no. 349, based after 7.0.1.
// * enderio-7.0-dev+c91c8ee6e :: dev (local) build for commit c91c8ee6e for version set 7.0.
fun getVersionString(): String {
if (System.getenv("BUILD_VERSION") != null) {
var buildVersion = System.getenv("BUILD_VERSION")
if (buildVersion.startsWith("v")) {
buildVersion = buildVersion.substring(1)
}
return buildVersion
}
val versionSeries: String by project
// If this is not a release, we're going to get the last tag, add the ci build number, then append -dev+<commit_hash>
val commitHash = shellRunAndRead("git rev-parse --short HEAD").trim();
val previousTagVersion = shellRunAndRead("git describe --tags --abbrev=0").trim();
// Extract the numeric component of the last version.
val versionRegex = Regex("""\d+(\.\d+)+""")
var currentVersion = versionRegex.find(previousTagVersion)?.value
if (currentVersion == null) {
// Fallback to version series if we're unable to discover the previous version.
currentVersion = "$versionSeries.0"
}
if (System.getenv("BUILD_NUMBER") != null) {
val buildNumber = System.getenv("BUILD_NUMBER")
return "$currentVersion.$buildNumber-nightly+$commitHash"
}
return "$versionSeries-dev+$commitHash"
}
fun shellRunAndRead(command: String): String {
val process = ProcessBuilder()
.command(command.split(" "))
.directory(rootProject.projectDir)
.start()
return process.inputStream.bufferedReader().readText()
}