Skip to content

Commit 2791ac8

Browse files
committed
Release ZomboidMod v2.4.0
2 parents 51ef6ad + 361b35a commit 2791ac8

File tree

8 files changed

+668
-667
lines changed

8 files changed

+668
-667
lines changed

build.gradle

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
plugins {
2-
// Apply the java plugin to add support for Java
3-
id 'java'
2+
// Apply the java plugin to add support for Java
3+
id 'java'
44

5-
// Facilitates building archives that serve as project distributions
6-
id 'distribution'
5+
// Facilitates building archives that serve as project distributions
6+
id 'distribution'
77
}
88
repositories {
9-
mavenCentral()
9+
mavenCentral()
1010
}
1111

1212
java {
13-
// ZomboidDoc can only be executed with Java 8
14-
toolchain {
15-
languageVersion = JavaLanguageVersion.of(8)
16-
}
13+
// ZomboidDoc can only be executed with Java 8
14+
toolchain {
15+
languageVersion = JavaLanguageVersion.of(8)
16+
}
1717
}
1818
apply from: 'setup.gradle'
1919
if (project.ext.has('gameDir'))
2020
{
21-
Set<String> sourcesList = new HashSet<>(['media/lua'])
22-
Set<String> resourcesList = new HashSet<>()
23-
Set<String> excludeResources = new HashSet<>([
24-
'media/lua', 'media/luaexamples',
25-
'media/newuitests', 'media/launcher',
26-
])
27-
def gameDirPath = gameDir as java.nio.file.Path
28-
//@formatter:off
21+
Set<String> sourcesList = new HashSet<>(['media/lua'])
22+
Set<String> resourcesList = new HashSet<>()
23+
Set<String> excludeResources = new HashSet<>([
24+
'media/lua', 'media/luaexamples',
25+
'media/newuitests', 'media/launcher',
26+
])
27+
def gameDirPath = gameDir as java.nio.file.Path
28+
//@formatter:off
2929
gameDirPath.resolve('media').toFile().listFiles().each
3030
{
3131
if (it.directory)
@@ -36,21 +36,20 @@ if (project.ext.has('gameDir'))
3636
}
3737
}
3838
}//@formatter:on
39-
sourceSets {
40-
media {
41-
java.srcDirs = sourcesList
42-
resources.srcDirs = resourcesList
43-
}
44-
}
45-
apply from: 'mod.gradle'
46-
apply from: 'zomboid.gradle'
47-
apply from: 'zdoc.gradle'
39+
sourceSets {
40+
media {
41+
java.srcDirs = sourcesList
42+
resources.srcDirs = resourcesList
43+
}
44+
}
45+
apply from: 'mod.gradle'
46+
apply from: 'zomboid.gradle'
47+
apply from: 'zdoc.gradle'
48+
49+
jar.from sourceSets.media.output
4850

49-
jar {
50-
from sourceSets.media.output
51-
}
52-
version modInfoProperties.getProperty('modversion')
53-
apply from: 'distribution.gradle'
51+
version modInfoProperties.getProperty('modversion')
52+
apply from: 'distribution.gradle'
5453

55-
defaultTasks 'showModInfo'
54+
defaultTasks 'showModInfo'
5655
}

dist/distribution.gradle

Lines changed: 101 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,102 @@
1-
import java.nio.file.Files
2-
import java.nio.file.Paths
3-
4-
// changelog.gradle
5-
apply from: 'https://git.io/JqJiC'
6-
7-
def getPathsRelativeToModule(moduleName, srcDirSet) {
8-
9-
def module = rootDir.toPath().resolve(moduleName)
10-
def map = new HashMap<String, String>()
11-
12-
def srcDirs = srcDirSet.srcDirs.stream().withCloseable {
13-
it.filter({ f -> f.exists() }).collect()
14-
}
15-
for (File srcDir : (srcDirs as List<File>))
16-
{
17-
Files.walk(srcDir.toPath()).withCloseable
18-
{
19-
def paths = it.filter({ Files.isRegularFile(it as java.nio.file.Path) }).collect()
20-
for (java.nio.file.Path path : (paths as List<java.nio.file.Path>))
21-
{
22-
def srcDirPath = srcDir.toPath()
23-
def relativePath = srcDirPath.relativize(path)
24-
def srcDirName = module.relativize(srcDirPath)
25-
map.put(relativePath.toString(), srcDirName.toString())
26-
}
27-
}
28-
}
29-
return map
30-
}
31-
32-
static def getRelativeCopyPath(fcd, relativePathMap) {
33-
34-
def path = relativePathMap.get(Paths.get(fcd.path).toString())
35-
if (path != null) {
36-
return fcd.relativePath.prepend(path)
37-
}
38-
else throw new Exception("Unable to relativize copy path: $fcd.path")
39-
}
40-
41-
def mediaClassesDir = "$buildDir/classes/lua/media"
42-
task mediaClasses(type: Copy, overwrite: true) {
43-
44-
into mediaClassesDir
45-
from(sourceSets.media.java.srcDirs) {
46-
def mSources = getPathsRelativeToModule('media', sourceSets.media.java)
47-
eachFile {
48-
def fcd = it as FileCopyDetails
49-
fcd.setRelativePath(getRelativeCopyPath(fcd, mSources))
50-
}
51-
}
52-
includeEmptyDirs = false
53-
}
54-
55-
processMediaResources {
56-
57-
includeEmptyDirs = false
58-
def mResources = getPathsRelativeToModule('media', sourceSets.media.resources)
59-
eachFile {
60-
def fcd = it as FileCopyDetails
61-
fcd.setRelativePath(getRelativeCopyPath(fcd, mResources))
62-
}
63-
}
64-
65-
def stagePath = "$buildDir/tmp/distribution/stage"
66-
task cleanModDistributionStage(type: Delete) {
67-
68-
description 'Clean distribution stage directory.'
69-
group 'distribution'
70-
71-
it.onlyIf {
72-
file(stagePath).exists()
73-
}
74-
delete(stagePath)
75-
}
76-
tasks.register('stageModDistribution', Copy.class) {
77-
78-
it.description 'Copy mod distribution files to stage directory.'
79-
it.group 'distribution'
80-
81-
it.from mediaClassesDir, "$buildDir/resources/media"
82-
it.into stagePath
83-
84-
it.dependsOn(cleanModDistributionStage)
85-
it.mustRunAfter('processMediaResources', 'mediaClasses')
86-
}
87-
88-
distributions {
89-
mod.contents {
90-
it.from stagePath
91-
it.into 'media'
92-
}
93-
}
94-
installModDist {
95-
def parentDir = destinationDir.parentFile.toPath()
96-
destinationDir = parentDir.resolve(rootProject.name).toFile()
97-
}
98-
[ 'modDistTar', 'modDistZip' ].forEach({
99-
def task = tasks.named(it).get() as AbstractArchiveTask
100-
task.archiveBaseName.set(rootProject.name)
101-
task.mustRunAfter('stageModDistribution')
102-
})
1+
import java.nio.file.Files
2+
import java.nio.file.Paths
3+
4+
// changelog.gradle
5+
apply from: 'https://git.io/JqJiC'
6+
7+
def getPathsRelativeToModule(moduleName, srcDirSet) {
8+
9+
def module = rootDir.toPath().resolve(moduleName)
10+
def map = new HashMap<String, String>()
11+
12+
def srcDirs = srcDirSet.srcDirs.stream().withCloseable {
13+
it.filter({ f -> f.exists() }).collect()
14+
}
15+
//@formatter:off
16+
for (File srcDir : (srcDirs as List<File>)) {
17+
Files.walk(srcDir.toPath()).withCloseable
18+
{
19+
def paths = it.filter({ Files.isRegularFile(it as java.nio.file.Path) }).collect()
20+
for (java.nio.file.Path path : (paths as List<java.nio.file.Path>)) {
21+
def srcDirPath = srcDir.toPath()
22+
def relativePath = srcDirPath.relativize(path)
23+
def srcDirName = module.relativize(srcDirPath)
24+
map.put(relativePath.toString(), srcDirName.toString())
25+
}
26+
}
27+
}//@formatter:on
28+
return map
29+
}
30+
31+
static def getRelativeCopyPath(fcd, relativePathMap) {
32+
33+
def path = relativePathMap.get(Paths.get(fcd.path).toString())
34+
if (path != null) {
35+
return fcd.relativePath.prepend(path)
36+
}
37+
else throw new Exception("Unable to relativize copy path: $fcd.path")
38+
}
39+
40+
def mediaClassesDir = "$buildDir/classes/lua/media"
41+
task mediaClasses(type: Copy, overwrite: true) {
42+
43+
into mediaClassesDir
44+
from(sourceSets.media.java.srcDirs) {
45+
def mSources = getPathsRelativeToModule('media', sourceSets.media.java)
46+
eachFile {
47+
def fcd = it as FileCopyDetails
48+
fcd.setRelativePath(getRelativeCopyPath(fcd, mSources))
49+
}
50+
}
51+
includeEmptyDirs = false
52+
}
53+
54+
processMediaResources {
55+
56+
includeEmptyDirs = false
57+
def mResources = getPathsRelativeToModule('media', sourceSets.media.resources)
58+
eachFile {
59+
def fcd = it as FileCopyDetails
60+
fcd.setRelativePath(getRelativeCopyPath(fcd, mResources))
61+
}
62+
}
63+
64+
def stagePath = "$buildDir/tmp/distribution/stage"
65+
task cleanModDistributionStage(type: Delete) {
66+
67+
description 'Clean distribution stage directory.'
68+
group 'distribution'
69+
70+
it.onlyIf {
71+
file(stagePath).exists()
72+
}
73+
delete(stagePath)
74+
}
75+
tasks.register('stageModDistribution', Copy.class) {
76+
77+
it.description 'Copy mod distribution files to stage directory.'
78+
it.group 'distribution'
79+
80+
it.from mediaClassesDir, "$buildDir/resources/media"
81+
it.into stagePath
82+
83+
it.dependsOn(cleanModDistributionStage)
84+
it.mustRunAfter('processMediaResources', 'mediaClasses')
85+
}
86+
87+
distributions {
88+
mod.contents {
89+
it.from stagePath
90+
it.into 'media'
91+
}
92+
}
93+
installModDist {
94+
def parentDir = destinationDir.parentFile.toPath()
95+
destinationDir = parentDir.resolve(rootProject.name).toFile()
96+
}
97+
['modDistTar', 'modDistZip'].forEach({
98+
def task = tasks.named(it).get() as AbstractArchiveTask
99+
task.archiveBaseName.set(rootProject.name)
100+
task.mustRunAfter('stageModDistribution')
101+
})
103102
assembleModDist.dependsOn('processMediaResources', 'mediaClasses', 'stageModDistribution')

0 commit comments

Comments
 (0)