-
Notifications
You must be signed in to change notification settings - Fork 300
/
addon.gradle
81 lines (73 loc) · 2.95 KB
/
addon.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
compileJava {
options.encoding = "UTF-8"
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
minecraft {
def vMajor, vMinor, vPatch, logLevel = LogLevel.INFO
try {
String version = project.version
def (five,major,minor,patch)= version.split("[.-]", 5)
vMajor = 500 + major.toInteger()
vMinor = minor.toInteger()
vPatch = patch.toInteger()
} catch (Exception ex) {
try {
String version = "git describe".execute().text
def (five,major,minor,patch)= version.split("[.-]", 5)
vMajor = 500 + major.toInteger()
vMinor = minor.toInteger()
vPatch = patch.toInteger()
logLevel = LogLevel.LIFECYCLE
} catch (Exception ex2) {
def err = "Cannot automatically determine NBT version. Using defaults hardcoded in buildscript. This could break your world!"
project.logger.error(err)
vMajor = 509
vMinor = 44
vPatch = 0
logLevel = LogLevel.WARN
}
}
injectedTags.put 'VERSION_MAJOR', vMajor
injectedTags.put 'VERSION_MINOR', vMinor
injectedTags.put 'VERSION_PATCH', vPatch
project.logger.log(logLevel, 'Using ({}, {}, {}) as NBT version', vMajor, vMinor, vPatch)
}
SourceSet functionalTestSet = null
sourceSets {
functionalTestSet = create("functionalTest") {
java {
srcDir("src/functionalTest/java")
compileClasspath += sourceSets.patchedMc.output + sourceSets.main.output
}
}
}
configurations { configs ->
// Keep all dependencies from the main mod in the functional test mod
named(functionalTestSet.compileClasspathConfigurationName).configure {it.extendsFrom(named("compileClasspath").get())}
named(functionalTestSet.runtimeClasspathConfigurationName).configure {it.extendsFrom(named("runtimeClasspath").get())}
named(functionalTestSet.annotationProcessorConfigurationName).configure {it.extendsFrom(named("annotationProcessor").get())}
}
tasks.register(functionalTestSet.jarTaskName, Jar) {
from(functionalTestSet.output)
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(new File(buildDir, "tmp"))
}
tasks.named("assemble").configure {
dependsOn(functionalTestSet.jarTaskName)
}
// Run tests in the default runServer/runClient configurations
tasks.named("runServer", JavaExec).configure {
dependsOn(functionalTestSet.jarTaskName)
classpath(configurations.named(functionalTestSet.runtimeClasspathConfigurationName), tasks.named(functionalTestSet.jarTaskName))
}
tasks.named("runClient", JavaExec).configure {
dependsOn(functionalTestSet.jarTaskName)
classpath(configurations.named(functionalTestSet.runtimeClasspathConfigurationName), tasks.named(functionalTestSet.jarTaskName))
}