generated from cocolabs/pz-zmod
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zdoc.gradle
92 lines (72 loc) · 2.91 KB
/
zdoc.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
import java.nio.charset.StandardCharsets
// directory containing generated lua library
project.ext.zDocLuaDir = file("$buildDir/generated/sources/zdoc/").absoluteFile
repositories {
// try to find dependencies locally first
mavenLocal()
}
// Github Packages repository credentials
project.ext.cocoLabsRepo = 'pz-zdoc'
apply from: 'https://git.io/JtydE'
configurations {
zomboidDoc.extendsFrom zomboidRuntimeOnly
}
dependencies {
// https://github.com/orgs/real-coco-labs/packages?repo_name=pz-zdoc
zomboidDoc 'io.cocolabs:pz-zdoc:3.+'
// ZomboidDoc compiled Lua library
if (project.ext.has('mod.pzversion')) {
compileOnly files("lib/zdoc-lua-${project.ext.get('mod.pzversion')}" + '.jar')
}
else if (file('mod.info').exists()) {
logger.warn('WARN: Unable to find mod.pzversion property')
}
// Project Zomboid classes
zomboidDoc files(zomboidClassesDir)
}
tasks.register('zomboidLuaJar', ZDocJar.class) {
it.description('Assembles a jar containing compiled lua classes.')
it.archiveBaseName.set('zdoc-lua')
it.from zDocLuaDir
it.destinationDir file('lib')
}
tasks.register('zomboidVersion', JavaExec.class) {
it.description('Read Project Zomboid game version.')
it.group('zomboid')
it.main = 'io.cocolabs.pz.zdoc.Main'
it.classpath = configurations.zomboidDoc
it.args 'version'
OutputStream oStream = new ByteArrayOutputStream()
it.setStandardOutput(oStream)
it.doLast {
// get command output from stream
def versionText = oStream.toString(StandardCharsets.UTF_8.name()).split('\r\n|\r|\n')
// ZomboidDoc version
logger.lifecycle(versionText[0])
// get version number and classifier (ex. 41.50-IWBUMS)
project.ext.set('mod.pzversion', versionText[1].substring(12).replaceAll(" ", "").trim())
logger.lifecycle("game version ${project.ext.get('mod.pzversion')}")
}
it.dependsOn(tasks.getByName('zomboidClasses'))
it.finalizedBy(tasks.getByName('saveModInfo'))
}
tasks.register('annotateZomboidLua', JavaExec.class) {
it.description('Annotate vanilla Lua with EmmyLua.')
it.setGroup('zomboid')
it.main = 'io.cocolabs.pz.zdoc.Main'
it.classpath = configurations.zomboidDoc
it.args('annotate', '-i', "${project.ext.gameDir}/media/lua", '-o', "$zDocLuaDir/media/lua")
it.dependsOn(tasks.getByName('zomboidClasses'))
}
tasks.register('compileZomboidLua', JavaExec.class) {
it.description('Compile Lua library from modding API.')
it.setGroup('zomboid')
//noinspection GroovyAssignabilityCheck,GroovyAccessibility
it.javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}
it.main = 'io.cocolabs.pz.zdoc.Main'
it.classpath = configurations.zomboidDoc
it.args('compile', '-i', "$gameDir", '-o', "$zDocLuaDir/media/lua/shared/Library")
it.dependsOn(tasks.getByName('zomboidClasses'))
}