|
1 | | -import java.nio.file.Files |
2 | | -import java.nio.file.Path |
| 1 | +// directory containing a copy of Project Zomboid classes |
| 2 | +project.ext.zomboidClassesDir = file("$buildDir/classes/zomboid").absoluteFile |
| 3 | + |
| 4 | +/** |
| 5 | + * This task will sync zomboidClassesDir with classes found in game install directory. |
| 6 | + * Note that it needs to run before dependencies are declared so that |
| 7 | + * the assembled classes can be included onto the classpath |
| 8 | + */ |
| 9 | +task zomboidClasses(type: Sync) { |
| 10 | + description 'Assembles zomboid classes.' |
| 11 | + group 'zomboid' |
| 12 | + includeEmptyDirs false |
| 13 | + from project.ext.gameDir |
| 14 | + include '**/*.class', 'stdlib.lbc' |
| 15 | + into zomboidClassesDir |
| 16 | +} |
| 17 | +classes.dependsOn(zomboidClasses) |
3 | 18 |
|
4 | 19 | configurations { |
| 20 | + runtimeOnly.extendsFrom zomboidRuntimeOnly |
5 | 21 | implementation.extendsFrom zomboidImplementation |
6 | 22 | } |
7 | 23 | dependencies { |
8 | 24 | // Project Zomboid libraries |
9 | | - zomboidImplementation fileTree(dir: gameDir, include: ['*.jar']) |
| 25 | + zomboidRuntimeOnly fileTree(dir: gameDir, include: ['*.jar']) |
10 | 26 |
|
11 | 27 | // Project Zomboid classes |
12 | | - zomboidImplementation files("lib/zomboid-$game_version" + '.jar') |
| 28 | + zomboidImplementation files(zomboidClassesDir) |
13 | 29 | } |
14 | | - |
15 | | -def zomboidJar = tasks.register("zomboidJar", Jar.class) { |
16 | | - it.onlyIf { |
17 | | - !project.ext.gameDir.empty |
18 | | - } |
19 | | - it.description('Assembles a jar archive containing game classes.') |
20 | | - it.setGroup('zomboid') |
21 | | - |
22 | | - it.archiveFileName = "zomboid-${game_version}.jar" |
23 | | - it.includeEmptyDirs = false |
24 | | - |
25 | | - it.from project.ext.gameDir |
26 | | - |
27 | | - HashSet<String> excludePaths = new HashSet<>() |
28 | | - Files.walk(project.ext.gameDir as Path).withCloseable |
29 | | - { |
30 | | - it.filter({Files.isRegularFile(it) && !it.fileName.toString().endsWith('class') && it.fileName.toString() != "stdlib.lbc" |
31 | | - }).collect().forEach({ excludePaths.add(gameDir.relativize(it as Path).toString()) }) |
32 | | - } |
33 | | - it.setExcludes(excludePaths) |
34 | | - it.doLast { |
35 | | - //noinspection GroovyAssignabilityCheck |
36 | | - copyJarOutputToLib(it) |
37 | | - } |
38 | | -} |
39 | | -jar.dependsOn(zomboidJar) |
40 | | - |
41 | 30 | /** |
42 | 31 | * Decompile game classes with FernFlower using default IDEA settings. |
43 | 32 | * Default task behaviour is to decompile all class files found in game root directory. |
|
0 commit comments