forked from GTNewHorizons/GT5-Unofficial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
102 lines (88 loc) · 3.65 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
102 lines (88 loc) · 3.65 KB
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
import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask
import java.util.regex.Pattern
plugins {
id("com.gtnewhorizons.gtnhconvention")
}
// workaround an OOM on GH actions during the checkStyleMain task
tasks.withType<Checkstyle>().configureEach {
maxHeapSize = "1g"
}
tasks.test.configure {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
fun parseGtVersion(versionStr: String): Triple<Int, Int, Int> {
val components = versionStr.split(Pattern.compile("[.-]"), 5)
val vMajor = 500 + components[1].toInt()
val vMinor = components[2].toInt()
val vPatch = components[3].toInt()
return Triple(vMajor, vMinor, vPatch)
}
var gtNbtVersion: Triple<Int, Int, Int> = Triple(509, 44, 0)
var logLevel = LogLevel.INFO
try {
val verStr = project.version.toString()
gtNbtVersion = parseGtVersion(verStr)
} catch (_: Exception) {
try {
val verStr = providers.exec {
commandLine("git", "describe")
}.standardOutput.asText.get()
gtNbtVersion = parseGtVersion(verStr)
logLevel = LogLevel.LIFECYCLE
} catch (_: Exception) {
logger.error("Cannot automatically determine NBT version. Using defaults hardcoded in buildscript. This could break your world!")
logLevel = LogLevel.WARN
}
}
minecraft {
injectedTags.put("VERSION_MAJOR", gtNbtVersion.first)
injectedTags.put("VERSION_MINOR", gtNbtVersion.second)
injectedTags.put("VERSION_PATCH", gtNbtVersion.third)
logger.log(logLevel, "Using {} as NBT version", gtNbtVersion)
}
val functionalTest by sourceSets.creating {
java {
srcDir("src/functionalTest/java")
compileClasspath += sourceSets.patchedMc.get().output + sourceSets.main.get().output
}
}
configurations {
// Keep all dependencies from the main mod in the functional test mod
named(functionalTest.compileClasspathConfigurationName).configure {extendsFrom(configurations.compileClasspath.get())}
named(functionalTest.runtimeClasspathConfigurationName).configure {extendsFrom(configurations.runtimeClasspath.get())}
named(functionalTest.annotationProcessorConfigurationName).configure {extendsFrom(configurations.annotationProcessor.get())}
}
tasks.register<Jar>(functionalTest.jarTaskName) {
archiveClassifier.set("functionalTests")
// we don't care about the version number here, keep it stable to avoid polluting the tmp directory
archiveVersion.set("1.0")
destinationDirectory.set(layout.buildDirectory.dir("tmp"))
}
tasks.assemble.configure {
dependsOn(functionalTest.jarTaskName)
}
// Run tests in the default runServer/runClient configurations
tasks.named<RunMinecraftTask>("runServer").configure {
dependsOn(functionalTest.jarTaskName)
classpath(configurations.named(functionalTest.runtimeClasspathConfigurationName), tasks.named(functionalTest.jarTaskName))
}
tasks.named<RunMinecraftTask>("runClient").configure {
dependsOn(functionalTest.jarTaskName)
classpath(configurations.named(functionalTest.runtimeClasspathConfigurationName), tasks.named(functionalTest.jarTaskName))
}
val recipeLookupValidationProperty = "gt.recipe.lookup.validate"
val runServer25RecipeLookupValidation = tasks.register("runServer25RecipeLookupValidation") {
group = "verification"
description = "Runs runServer25 with recipe lookup validation enabled."
dependsOn("runServer25")
}
tasks.named<RunMinecraftTask>("runServer25").configure {
if (gradle.startParameter.taskNames.any {
it == runServer25RecipeLookupValidation.name || it.endsWith(":${runServer25RecipeLookupValidation.name}")
}) {
jvmArgs("-D$recipeLookupValidationProperty=true")
}
}