generated from TropheusJ/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.gradle
227 lines (188 loc) · 6.26 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import io.github.fabricators_of_create.porting_lib_build.tasks.FmjExpander
import io.github.fabricators_of_create.porting_lib_build.PortingLibBuildPlugin
plugins {
id "fabric-loom"
id "maven-publish"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = "porting_lib"
Provider<String> branchProvider = providers.exec {
it.setCommandLine("git", "branch", "--show-current")
}.standardOutput.asText.map {
it.contains("not a git repository") ? "unknown" : it.trim()
}
String versionNumber = providers.provider {
String version = mod_version // 2.3.1
if (System.getenv("SNAPSHOT") == "true") {
version += "-beta." + System.getenv("GITHUB_RUN_NUMBER") // 2.3.1-beta.1000
}
return version + "+" + branchProvider.get() // 2.3.1-beta.1000+1.20.1
}.get()
dependencies {
subprojects.forEach {
api(include(project(path: ":$it.name", configuration: "namedElements")))
}
}
processResources {
// exclude the template from the fat jar
exclude("template.fabric.mod.json")
}
// resets the changelog and bumps the version after an automated release.
tasks.register("postRelease") {
String nextVersion = project.hasProperty("nextVersion") ? project.property("nextVersion") : null
File changelog = rootProject.file("CHANGELOG.txt")
File props = rootProject.file("gradle.properties")
String currentVersion = mod_version
doFirst {
if (nextVersion == null) {
throw new RuntimeException("nextVersion property is not defined")
}
changelog.setText("")
String properties = props.getText()
properties = properties.replace(currentVersion, nextVersion)
props.setText(properties)
}
}
allprojects {
if (name == "buildSrc") return
apply plugin: "fabric-loom"
apply plugin: PortingLibBuildPlugin
group = "io.github.fabricators_of_create.Porting-Lib"
version = versionNumber
repositories {
mavenCentral()
maven { url = "https://maven.quiltmc.org/repository/release" }
maven { url = "https://hephaestus.dev/release" }
maven { url = "https://api.modrinth.com/maven" }
maven { url = "https://maven.bai.lol" }
maven { url = "https://maven.terraformersmc.com/releases/" }
maven { url = "https://maven.parchmentmc.org" }
maven { url = "https://maven.shedaniel.me/" }
maven { url = "https://mvn.devos.one/releases/" }
maven { url = "https://mvn.devos.one/snapshots/" }
maven { url = "https://maven.wispforest.io" }
maven { url = "https://cursemaven.com" }
maven { url = "https://maven.vram.io" }
maven {
url = "https://jitpack.io"
content {
includeGroup("com.github.Chocohead")
}
}
maven {
url = "https://maven.jamieswhiteshirt.com/libs-release"
content {
includeGroup "com.jamieswhiteshirt"
}
}
}
dependencies {
// dev environment
minecraft("com.mojang:minecraft:$minecraft_version")
mappings(loom.layered {
it.officialMojangMappings { nameSyntheticMembers = false }
if (parchment_version != "none")
it.parchment("org.parchmentmc.data:parchment-$minecraft_version:$parchment_version@zip")
})
modImplementation("net.fabricmc:fabric-loader:$loader_version")
modLocalRuntime("com.terraformersmc:modmenu:$modmenu_version") { exclude group: "net.fabricmc"; exclude group: "net.fabricmc.fabric-api" }
// common dependencies
// each module can also specify additional ones
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabric_api_version")
implementation("javax.annotation:javax.annotation-api:1.3.2")
implementation("com.google.code.findbugs:jsr305:3.0.2")
if (mixin_extras_version != "none")
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${mixin_extras_version}")))
}
loom {
runs.configureEach {
ideConfigGenerated = true // loom doesn't gen runs for subprojects, unless this is set to true.
vmArg("-Dmixin.debug.export=true") // export all mixins
}
}
configurations.configureEach {
// fixes loom using a loader version from a dependency
resolutionStrategy.force("net.fabricmc:fabric-loader:$loader_version")
}
processResources {
Map<String, ?> properties = [
version: version,
loader_version: loader_version,
fabric_api_version: fabric_api_version,
minecraft_dependency: minecraft_dependency,
java_version: sourceCompatibility,
// property replacement is a bit too eager
class_5124: "\$class_5124",
class_56: "\$class_56"
]
properties.forEach(inputs::property)
if (project != rootProject) { // expand subproject FMJs. Must be done here for proper ordering.
filesMatching("fabric.mod.json", new FmjExpander.Applicator(project))
}
filesMatching("fabric.mod.json") {
expand properties
}
}
jar.from(rootProject.file("LICENSE")) // copy license file into jar
}
subprojects {
apply plugin: "maven-publish"
archivesBaseName = "porting_lib_" + name
loom {
runs.configureEach {
File output = file("src/main/resources/data/porting_lib_$name/structures/gametest")
property("porting_lib.gametest.quickexport.output", output.absolutePath)
}
mods.register("porting_lib_" + name) {
sourceSet sourceSets.main
}
File aw = file("src/main/resources/porting_lib_${name}.accesswidener")
if (aw.exists())
accessWidenerPath.set(aw)
}
// these two modules are used by all others automatically.
if (name != "core" && name != "gametest") {
portingLib {
addModuleDependency("core") // core depends on gametest
}
}
validateModule {
projectName = project.name
readMe.set(rootProject.file("README.md"))
resources.set(project.file("src/main/resources"))
}
sortAccessWidener {
File awFile = project.file("src/main/resources/${project.name}.accesswidener")
if (awFile.exists())
aw.set(awFile)
}
processResources {
// include icon
into("assets/porting_lib") {
from(rootProject.file("src/main/resources/assets/porting_lib/icon.png"))
}
}
java.withSourcesJar()
publishing {
repositories {
maven {
name = "devOS"
String mavenType = System.getenv("RELEASE") == "true" ? "releases" : "snapshots"
url = "https://mvn.devos.one/$mavenType/"
credentials {
username = System.getenv("MAVEN_USER")
password = System.getenv("MAVEN_PASS")
}
authentication {
register("basic", BasicAuthentication)
}
}
}
publications {
register("mavenJava", MavenPublication) {
from((SoftwareComponent) components["java"])
}
}
}
}