-
Notifications
You must be signed in to change notification settings - Fork 10
/
zomboid.gradle
76 lines (61 loc) · 2.47 KB
/
zomboid.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
// directory containing Project Zomboid classes
project.ext.zomboidClassesDir = file("$buildDir/classes/zomboid").absoluteFile
// directory containing Project Zomboid sources
project.ext.zomboidSourcesDir = file("$buildDir/generated/sources/zomboid").absoluteFile
/**
* Decompile game classes with FernFlower using default IDEA settings.
* Default task behaviour is to decompile all class files found in game root directory.
*
* This can be changed by defining specific file to decompile with project property 'src'.
* example: gradle decompileZomboid -Psrc="<path>"
*/
tasks.register('decompileZomboid', JavaExec.class) {
it.description 'Decompile Project Zomboid classes.'
it.group 'zomboid'
if (project.ext.ideaHome == null) {
throw new InvalidUserDataException('Local property \"ideaHome\" is not defined')
}
it.onlyIf {
def files = zomboidClassesDir.exists() ? zomboidClassesDir.listFiles() : null
return files != null && files.size() > 0
}
//noinspection GroovyAssignabilityCheck,GroovyAccessibility
it.javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
it.classpath files("$ideaHome/plugins/java-decompiler/lib/java-decompiler.jar")
it.main 'org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler'
// default parameters used by IDEA compiler
def params = ['-hdc=0', '-dgs=1', '-rsy=1', '-rbr=1', '-lit=1', '-nls=1', '-mpm=60']
// decompiler will throw error if destination dir doesn't exist
zomboidSourcesDir.mkdirs()
it.args params + zomboidClassesDir.path + zomboidSourcesDir.path
it.dependsOn(zomboidClasses)
}
tasks.register('zomboidJar', Jar.class) {
it.description 'Assembles a jar archive containing game classes.'
it.group 'zomboid'
it.onlyIf {
def files = zomboidClassesDir.exists() ? zomboidClassesDir.listFiles() : null
return files != null && files.size() > 0
}
it.includeEmptyDirs = false
it.archiveBaseName.set('zomboid')
it.archiveVersion.set('')
it.from zomboidClassesDir
it.destinationDir file('lib')
it.dependsOn(zomboidClasses)
}
tasks.register("zomboidSourcesJar", Jar.class) {
it.description 'Assembles a jar containing decompiled game sources.'
it.group 'zomboid'
it.onlyIf {
def files = zomboidSourcesDir.exists() ? zomboidSourcesDir.listFiles() : null
return files != null && files.size() > 0
}
it.archiveBaseName.set('zomboid')
it.archiveVersion.set('')
it.classifier 'sources'
it.from zomboidSourcesDir
it.destinationDir file('lib')
}