forked from TechReborn/TechReborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
290 lines (244 loc) · 7.55 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
plugins {
id 'java'
id 'groovy'
id 'java-library'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'me.modmuss50.mod-publish-plugin' version '0.3.3'
}
repositories {
maven {
name "REI"
url "https://maven.shedaniel.me/"
content {
includeGroup "me.shedaniel"
includeGroup "me.shedaniel.cloth"
includeGroup "dev.architectury"
}
}
mavenCentral()
}
def ENV = System.getenv()
group = 'TechReborn'
allprojects {
version = project.mod_version + (ENV.GITHUB_ACTIONS ? "" : "+local")
apply plugin: "fabric-loom"
apply plugin: "maven-publish"
loom {
runtimeOnlyLog4j = true
splitEnvironmentSourceSets()
mixin {
useLegacyMixinAp = false
}
}
// Shared deps between TR and RC
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_version}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
//Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fapi_version}"
include(modApi("teamreborn:energy:${project.energy_version}")) {
transitive = false
}
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
publishing {
publications {
register("maven", MavenPublication) {
groupId project.name
artifactId project.base.archivesName.get() + "-" + (ENV.GITHUB_REF_NAME ?: "local")
version project.version
from components.java
}
}
repositories {
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
}
}
}
}
processResources {
doLast {
// Depend on the reborn core version it was built against
fileTree(dir: outputs.files.asPath, include: "fabric.mod.json").each {
def jsonSlurper = new JsonSlurper()
def modJson = jsonSlurper.parseText(it.text)
modJson.depends.reborncore = "~${project.version}"
it.text = JsonOutput.toJson(modJson)
}
}
}
loom {
accessWidenerPath = file("src/main/resources/techreborn.accesswidener")
}
sourceSets {
// Add a data gen sourceset
datagen {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += main.output
runtimeClasspath += main.output
}
gametest {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += main.output
runtimeClasspath += main.output
}
main {
resources {
srcDirs += [
'src/main/generated'
]
}
}
}
allprojects {
loom {
mods {
reborncore {
sourceSet project(":RebornCore").sourceSets.main
sourceSet project(":RebornCore").sourceSets.client
}
techreborn {
sourceSet project(":").sourceSets.main
sourceSet project(":").sourceSets.client
}
"techreborn-datagen" {
sourceSet project(":").sourceSets.datagen
}
"techreborn-gametest" {
sourceSet project(":").sourceSets.gametest
}
}
}
}
// TechReborn specific dependencies
dependencies {
api project(path: ":RebornCore", configuration: "namedElements")
clientImplementation project(":RebornCore").sourceSets.client.output
include project(":RebornCore")
optionalClientDependency("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}", true)
// Use groovy for datagen/gametest, if you are copying this you prob dont want it.
gametestImplementation 'org.apache.groovy:groovy:4.0.10'
datagenImplementation 'org.apache.groovy:groovy:4.0.10'
gametestImplementation ("com.google.truth:truth:1.1.3") {
exclude module: "guava"
exclude module: "asm"
}
}
def optionalClientDependency(String dep, runtime = true) {
def exclude = {
exclude group: "net.fabricmc.fabric-api"
exclude group: "net.fabricmc"
}
dependencies.modClientCompileOnly(dep, exclude)
if (runtime) {
dependencies.modClientRuntimeOnly(dep, exclude)
}
}
loom {
runs {
// Add a data gen run config
datagen {
server()
name "Data Generation"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}"
vmArg "-Dfabric-api.datagen.modid=techreborn-datagen"
runDir "build/datagen"
source sourceSets.datagen
}
// Use to run the tests
gametest {
server()
name "Game Test"
vmArg "-Dfabric-api.gametest"
vmArg "-Dfabric-api.gametest.report-file=${project.buildDir}/junit.xml"
runDir "build/gametest"
source sourceSets.gametest
}
// Use to debug tests
gametestClient {
client()
name "Game Test Client"
source sourceSets.gametest
}
}
}
runDatagen {
// Doesn't re-run the task when its up-to date
outputs.dir('src/main/generated')
}
tasks.sourcesJar.dependsOn runDatagen
jar {
exclude "**/*.psd"
from file('src/main/generated')
// A bit of a hack to allow the generated sources when they already exist
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn 'runDatagen'
}
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
publishMods {
changelog = providers.environmentVariable("CHANGELOG").orElse("No changelog provided")
version = project.version
type = providers.environmentVariable("RELEASE_CHANNEL").orElse("release").map {it == "release" ? STABLE : BETA }
modLoaders.add("fabric")
dryRun = providers.environmentVariable("CURSEFORGE_API_KEY").getOrNull() == null
def options = curseforgeOptions {
accessToken = providers.environmentVariable("CURSEFORGE_API_KEY")
minecraftVersions.add("1.20.4")
requires {
slug = "fabric-api"
}
}
curseforge("curseforgeTechReborn") {
from options
projectId = "233564"
file = remapJar.archiveFile
requires {
slug = "reborncore"
}
optional {
slug = "roughly-enough-items"
}
}
curseforge("curseforgeRebornCore") {
from options
projectId = "237903"
file = project(":RebornCore").tasks.remapJar.archiveFile
displayName = "RebornCore ${project.version}"
}
github {
file = remapJar.archiveFile
additionalFiles.from project(":RebornCore").tasks.remapJar.archiveFile
repository = providers.environmentVariable("GITHUB_REPOSITORY").orElse("dryrun")
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = providers.environmentVariable("GITHUB_REF_NAME").orElse("dryrun")
}
}