-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
279 lines (243 loc) · 8.1 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
plugins {
id 'net.neoforged.moddev'
id 'maven-publish'
id 'com.gradleup.shadow'
}
apply plugin: ProjectDefaultsPlugin
apply plugin: FlatBuffersPlugin
group = "appeng"
base {
archivesName = "guideme"
}
configurations {
localRuntimeOnly
shaded {
transitive = false
}
// Dependencies only used for the guide export, but not shipped
guideExportOnly
configurations.compileClasspath.extendsFrom(guideExportOnly)
configurations.runtimeClasspath.extendsFrom(guideExportOnly)
runtimeClasspath.extendsFrom localRuntimeOnly
}
dependencies {
// To be copied into the jar file
shaded project(path: ':markdown', configuration: "archives")
shaded "io.methvin:directory-watcher:${directory_watcher_version}"
shaded "org.yaml:snakeyaml:${snakeyaml_version}"
shaded "com.google.flatbuffers:flatbuffers-java:${flatbuffers_version}"
api(project(':markdown')) {
transitive = false
}
// Do not inherit any transitive dependencies here since we rely on those transitive dependencies being
// present in Minecrafts own dependencies already.
implementation("io.methvin:directory-watcher:${directory_watcher_version}") {
transitive = false
}
implementation("org.yaml:snakeyaml:${snakeyaml_version}") {
transitive = false
}
implementation("com.google.flatbuffers:flatbuffers-java:${flatbuffers_version}") {
transitive = false
}
// Used for the guide export
guideExportOnly("org.bytedeco:ffmpeg-platform:${ffmpeg_version}")
// unit test dependencies
testImplementation(platform("org.junit:junit-bom:${junit_version}"))
testImplementation(platform("org.assertj:assertj-bom:${assertj_version}"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core")
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")
testImplementation("net.neoforged:testframework:${neoforge_version}")
}
///////////////////
// Version Number
ext.tag = System.getenv('TAG') ?: ""
if (ext.tag) {
if (!ext.tag.startsWith("v")) {
throw new GradleException("Tags should start with v ${ext.tag}")
}
project.version = ext.tag.substring("v".length())
} else {
// This essentially tries to implement delay expansion of the project version based on a value source to
// still support configuration caching.
project.version = providers.gradleProperty("version").orElse("").flatMap(version -> {
if (!version.isBlank()) {
return providers.provider { version }
}
return providers.of(ProjectVersionSource.class, spec -> {
spec.getParameters().getDefaultBranches().addAll("main", project.minecraft_version)
});
}).get()
}
tasks.register("printProjectVersion", PrintProjectVersion.class);
test {
useJUnitPlatform()
// Might not need this anymore...
systemProperty "guideDev.ae2guide.sources", file("guidebook").absolutePath
}
/**
* Configures properties common to all run configurations
*/
Map<String, String> commonSystemProperties = [
'forge.logging.console.level': 'debug',
'appeng.tests' : 'true',
]
neoForge {
version = project.neoforge_version
mods {
guideme {
sourceSet sourceSets.main
}
}
runs {
configureEach {
gameDirectory = project.file('run')
systemProperties = commonSystemProperties
// property "mixin.debug.export", "true"
additionalRuntimeClasspathConfiguration.extendsFrom configurations.shaded
additionalRuntimeClasspathConfiguration.extendsFrom configurations.guideExportOnly
}
client {
client()
systemProperties = [
* : commonSystemProperties,
"appeng.tests" : "true",
"guideDev.ae2guide.sources": file("guidebook").absolutePath,
]
}
gametestWorld {
client()
programArguments = [
"--username", "GuideMEDev", "--quickPlaySingleplayer", "GametestWorld"
]
systemProperties = [
"appeng.tests" : "true",
"guideDev.ae2guide.sources": file("guidebook").absolutePath,
]
}
guide {
client()
systemProperties = [
"guideDev.ae2guide.sources" : file("guidebook").absolutePath,
"guideDev.ae2guide.startupPage": "ae2:index.md"
]
}
data {
data()
programArguments = [
'--mod', 'guideme',
'--all',
'--output', file('src/generated/resources/').absolutePath,
'--existing', file('src/main/resources').absolutePath
]
}
guideexport {
client()
systemProperties = [
"appeng.runGuideExportAndExit": "true",
"appeng.guideExportFolder" : file("$buildDir/guide").absolutePath,
"guideDev.ae2guide.sources" : file("guidebook").absolutePath,
"appeng.version" : project.version
]
}
// Use to run the tests
gametest {
type = "gameTestServer"
gameDirectory = project.file("build/gametest")
}
}
unitTest {
enable()
testedMod = mods.guideme
}
}
//////////////
// Artifacts
Map<String, String> expansionVariables = [
'project_version': project.version,
'minecraft_version': project.minecraft_version_range,
'neoforge_version': project.neoforge_version_range,
]
processResources {
// Ensure the resources get re-evaluate when the version changes
for (var entry : expansionVariables.entrySet()) {
inputs.property(entry.key, entry.value)
}
filesMatching("META-INF/neoforge.mods.toml") {
expand expansionVariables
filter { line ->
line.replace('version="0.0.0"', "version=\"${expansionVariables['project_version']}\"")
}
}
}
jar {
finalizedBy shadowJar
archiveClassifier = "plain"
}
shadowJar {
from sourceSets.main.output.classesDirs
from sourceSets.main.output.resourcesDir
relocate "io.methvin", "appeng.shaded.methvin"
relocate "org.yaml.snakeyaml", "appeng.shaded.snakeyaml"
configurations = [project.configurations.shaded]
archiveClassifier = ""
}
assemble.dependsOn shadowJar
def publicApiIncludePatterns = {
exclude "**/*Internal.*"
exclude "**/*Internal\$*.*"
include "appeng/api/**"
}
javadoc {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath + sourceSets.main.output
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
}
javadoc publicApiIncludePatterns
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = "javadoc"
from javadoc.destinationDir
}
tasks.register('sourcesJar', Jar) {
archiveClassifier = "sources"
from sourceSets.main.allJava
}
tasks.register('apiJar', Jar) {
archiveClassifier = "api"
// api jar ist just a development aid and serves as both a binary and source jar simultaneously
from sourceSets.main.output
from sourceSets.main.allJava
}
apiJar publicApiIncludePatterns
artifacts {
archives javadocJar
archives sourcesJar
archives apiJar
}
//////////////////
// Maven publish
publishing {
publications {
maven(MavenPublication) {
artifactId = "guideme"
version = project.version
artifact shadowJar
artifact sourcesJar
artifact javadocJar
artifact apiJar
}
}
repositories {
maven {
name = "Local"
url = file("build/repo").toURI()
}
}
}