Skip to content

Commit c368f4c

Browse files
committed
Improve zomboid class resolution
1 parent 9e7c09f commit c368f4c

File tree

3 files changed

+21
-55
lines changed

3 files changed

+21
-55
lines changed

.idea/runConfigurations/zomboidJar.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

zdoc.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ repositories {
22
maven { url 'https://jitpack.io' }
33
}
44
configurations {
5-
zomboidDoc
5+
zomboidDoc.extendsFrom zomboidRuntimeOnly
66
}
77
dependencies {
88
// https://github.com/real-coco-labs/pz-zdoc

zomboid.gradle

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,32 @@
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)
318

419
configurations {
20+
runtimeOnly.extendsFrom zomboidRuntimeOnly
521
implementation.extendsFrom zomboidImplementation
622
}
723
dependencies {
824
// Project Zomboid libraries
9-
zomboidImplementation fileTree(dir: gameDir, include: ['*.jar'])
25+
zomboidRuntimeOnly fileTree(dir: gameDir, include: ['*.jar'])
1026

1127
// Project Zomboid classes
12-
zomboidImplementation files("lib/zomboid-$game_version" + '.jar')
28+
zomboidImplementation files(zomboidClassesDir)
1329
}
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-
4130
/**
4231
* Decompile game classes with FernFlower using default IDEA settings.
4332
* Default task behaviour is to decompile all class files found in game root directory.

0 commit comments

Comments
 (0)