From e47c9b5e9bb6b30db6a6f9aec98a4088fe0ad60d Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Sat, 27 Feb 2021 23:05:53 +0100 Subject: [PATCH 01/40] Move distribution template files --- dist/{ => docs/template}/LICENSE.txt | 0 dist/{ => docs/template}/README.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename dist/{ => docs/template}/LICENSE.txt (100%) rename dist/{ => docs/template}/README.md (100%) diff --git a/dist/LICENSE.txt b/dist/docs/template/LICENSE.txt similarity index 100% rename from dist/LICENSE.txt rename to dist/docs/template/LICENSE.txt diff --git a/dist/README.md b/dist/docs/template/README.md similarity index 100% rename from dist/README.md rename to dist/docs/template/README.md From 27a1387a135749a46742f0c18776b015b835bf0b Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Sat, 27 Feb 2021 23:07:12 +0100 Subject: [PATCH 02/40] Fix distribution directory staging Staging directories was throwing an error. --- distribution.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/distribution.gradle b/distribution.gradle index bf01724..34f3015 100644 --- a/distribution.gradle +++ b/distribution.gradle @@ -28,7 +28,10 @@ tasks.register('stageDistribution', Copy.class) { // do additional copy actions we cannot do with this Copy task it.doLast { file('dist').listFiles().each { - GFileUtils.copyFile(it, stagePath.resolve(it.getName()).toFile() as File) + if (it.directory) { + GFileUtils.copyDirectory(it, stagePath.resolve(it.getName()).toFile() as File) + } + else GFileUtils.copyFile(it, stagePath.resolve(it.getName()).toFile() as File) } def gitIgnored = file('.gitignored') if (gitIgnored.exists()) From f50da35e260dfa21aca5baaab91bcc29811b3339 Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Sun, 28 Feb 2021 00:43:06 +0100 Subject: [PATCH 03/40] Move readme images --- README.md | 14 +++++++------- {media/zmod => images}/init_mod.gif | Bin {media/zmod => images}/load_gradle_project.png | Bin {media/zmod => images}/module_dependencies.png | Bin {media/zmod => images}/module_library.png | Bin {media/zmod => images}/open_project.png | Bin {media/zmod => images}/project_search_scopes.png | Bin {media/zmod => images}/update_run_configs.png | Bin 8 files changed, 7 insertions(+), 7 deletions(-) rename {media/zmod => images}/init_mod.gif (100%) rename {media/zmod => images}/load_gradle_project.png (100%) rename {media/zmod => images}/module_dependencies.png (100%) rename {media/zmod => images}/module_library.png (100%) rename {media/zmod => images}/open_project.png (100%) rename {media/zmod => images}/project_search_scopes.png (100%) rename {media/zmod => images}/update_run_configs.png (100%) diff --git a/README.md b/README.md index 7012ed1..609b505 100644 --- a/README.md +++ b/README.md @@ -61,15 +61,15 @@ Instead, obtain the latest release and follow the [installation](#installation) -
Open the project as a Gradle project with Intellij IDEA?. -
-
+
+
- Ensure project SDK is set to JDK 8[?](https://www.jetbrains.com/help/idea/sdk.html#change-project-sdk). -
Initialize mod by running initializeMod run configuration?. -
+
- Prepare workspace by running `setupWorkspace` run configuration[?](https://www.jetbrains.com/help/idea/run-debug-configuration.html). @@ -78,20 +78,20 @@ Instead, obtain the latest release and follow the [installation](#installation) -
Attach decompiled sources to classes. -
-

+
+

-
Update application run configurations.

Set application configurations module field to <mod_id>.main. For example if your mod ID was awesome-mod you would set the module field to awesome-mod.main.

-
+
-
Update project search scopes.

Navigate to File -> Settings -> Appearance & Behaviour -> Scopes and update all search scope module references to match your project module. For example if your mod ID was awesome-mod you would set the module field to awesome-mod.media.

-
+
### License diff --git a/media/zmod/init_mod.gif b/images/init_mod.gif similarity index 100% rename from media/zmod/init_mod.gif rename to images/init_mod.gif diff --git a/media/zmod/load_gradle_project.png b/images/load_gradle_project.png similarity index 100% rename from media/zmod/load_gradle_project.png rename to images/load_gradle_project.png diff --git a/media/zmod/module_dependencies.png b/images/module_dependencies.png similarity index 100% rename from media/zmod/module_dependencies.png rename to images/module_dependencies.png diff --git a/media/zmod/module_library.png b/images/module_library.png similarity index 100% rename from media/zmod/module_library.png rename to images/module_library.png diff --git a/media/zmod/open_project.png b/images/open_project.png similarity index 100% rename from media/zmod/open_project.png rename to images/open_project.png diff --git a/media/zmod/project_search_scopes.png b/images/project_search_scopes.png similarity index 100% rename from media/zmod/project_search_scopes.png rename to images/project_search_scopes.png diff --git a/media/zmod/update_run_configs.png b/images/update_run_configs.png similarity index 100% rename from media/zmod/update_run_configs.png rename to images/update_run_configs.png From 601fa43dc9319c4e762921880467c6190d0c26d7 Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 1 Mar 2021 22:21:54 +0100 Subject: [PATCH 04/40] Change dist stage directory --- distribution.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution.gradle b/distribution.gradle index 34f3015..3ca1644 100644 --- a/distribution.gradle +++ b/distribution.gradle @@ -1,6 +1,6 @@ import org.gradle.util.GFileUtils -def stagePath = file("$buildDir/tmp/distribution/stage").toPath() +def stagePath = file("stage").toPath() task cleanDistributionStage(type: Delete) { description('Clean distribution stage directory.') From 09f90b2fea3af90de375e39bf99a389be6968a5e Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 1 Mar 2021 22:22:28 +0100 Subject: [PATCH 05/40] Optimize cleanDistributionStage task --- distribution.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/distribution.gradle b/distribution.gradle index 3ca1644..671d8ab 100644 --- a/distribution.gradle +++ b/distribution.gradle @@ -5,7 +5,9 @@ task cleanDistributionStage(type: Delete) { description('Clean distribution stage directory.') group('distribution') - + it.onlyIf { + file(stagePath).exists() + } delete(stagePath) } tasks.register('stageDistribution', Copy.class) { From 4caafdb9c6c7596e2c1762f5d21ba6c81d6349d0 Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 1 Mar 2021 22:23:30 +0100 Subject: [PATCH 06/40] Store dist docs in dedicated dir --- dist/.gitignore | 4 ++++ distribution.gradle | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dist/.gitignore b/dist/.gitignore index 2dd8a26..f77ab53 100644 --- a/dist/.gitignore +++ b/dist/.gitignore @@ -4,6 +4,10 @@ local.properties # Libraries /lib/ +# Template +/docs/template/ +/docs/zmod/ + ### IntelliJ ### # Project file-based format diff --git a/distribution.gradle b/distribution.gradle index 671d8ab..b9b1bf7 100644 --- a/distribution.gradle +++ b/distribution.gradle @@ -10,6 +10,7 @@ task cleanDistributionStage(type: Delete) { } delete(stagePath) } +def docsList = [ 'README.md', 'LICENSE.txt', 'CHANGELOG.md' ] tasks.register('stageDistribution', Copy.class) { description('Copy distribution files to stage directory.') @@ -19,14 +20,18 @@ tasks.register('stageDistribution', Copy.class) { it.into stagePath // files that need to be excluded - it.exclude '/README.md', '/LICENSE.txt', '/.gitignore', - '.gitignored', 'distribution.sh', 'distribution.gradle', + it.exclude '/.gitignore', '.gitignored', 'distribution.sh', 'distribution.gradle', '.idea/runConfigurations/distribution.xml', 'mod.info' // dirs that are already excluded but we don't want to spend time on staging it.exclude '/dist/**', '.gradle/**', 'buildSrc/.gradle/**', '/build/**', 'buildSrc/build/**', '/lib/**', '/media/**', '/logs/**' + // include project documentation + it.into('docs/zmod') { + it.from projectDir + it.include docsList + 'images/*' + } // do additional copy actions we cannot do with this Copy task it.doLast { file('dist').listFiles().each { From 408b9d86f1070874d9c0ea60453685ce02038bb9 Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 1 Mar 2021 22:26:49 +0100 Subject: [PATCH 07/40] Fix distribution including ignored files The exclusion system for staging distribution files did not work properly. --- distribution.gradle | 37 ++++++++++++++++++++++++++++--------- distribution.sh | 22 ++++++++++++++++++++-- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/distribution.gradle b/distribution.gradle index b9b1bf7..f3722c5 100644 --- a/distribution.gradle +++ b/distribution.gradle @@ -35,20 +35,39 @@ tasks.register('stageDistribution', Copy.class) { // do additional copy actions we cannot do with this Copy task it.doLast { file('dist').listFiles().each { + /* + * copy additional distribution files manually because files + * excluded by task filters cannot be copied with Copy task + */ if (it.directory) { GFileUtils.copyDirectory(it, stagePath.resolve(it.getName()).toFile() as File) } else GFileUtils.copyFile(it, stagePath.resolve(it.getName()).toFile() as File) } - def gitIgnored = file('.gitignored') - if (gitIgnored.exists()) - { - def ignoredFiles = GFileUtils.readFile(gitIgnored).split('\r|\n|\r\n') - ignoredFiles.each { - File ignoredFile = stagePath.resolve(it).normalize().toFile() - if (ignoredFile.exists() && !ignoredFile.isDirectory() && !ignoredFile.delete()) { - logger.warn("WARN: Unable to delete ${ignoredFile.path}") - } + // remove duplicate docs in root directory + docsList.forEach({ + GFileUtils.deleteQuietly(stagePath.resolve(it).toFile()) + }) + } + it.dependsOn(cleanDistributionStage) +} + +tasks.register('pruneDistributionStage', Delete.class) { + + final def task = it + it.onlyIf { + file(stagePath).exists() + } + def gitIgnored = file('.gitignored') + if (gitIgnored.exists()) + { + def ignoredFiles = GFileUtils.readFile(gitIgnored).split('\r|\n|\r\n') + ignoredFiles.each { + File ignoredFile = file(it) + if (ignoredFile.toPath().toAbsolutePath().startsWith(stagePath.toAbsolutePath())) + { + task.delete(ignoredFile) + logger.quiet("Deleting ignored file ${it}") } } } diff --git a/distribution.sh b/distribution.sh index d250c9c..89c4bb0 100644 --- a/distribution.sh +++ b/distribution.sh @@ -1,8 +1,26 @@ #!/bin/bash -echo Listing files ignored by git... + +printf 'Staging distribution...\n' +./gradlew stageDistribution + +printf '\nListing files ignored by git...\n' + +# disable distribution gitignore +mv stage/.gitignore stage/.gitignore_ + find . -path ./.git -prune -o -print | git check-ignore --no-index --stdin > .gitignored -echo Assembling distribution... +# enable distribution gitignore +mv stage/.gitignore_ stage/.gitignore + +printf '\nPruning distribution stage...\n' +./gradlew pruneDistributionStage + +printf '\nAssembling distribution...\n' ./gradlew assembleDist +printf '\nCleaning distribution stage...\n' +./gradlew cleanDistributionStage + +printf '\n' read -p "Press enter to continue" From 221490e84e159230f55ca652582ad4ea3ed78574 Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 1 Mar 2021 22:27:09 +0100 Subject: [PATCH 08/40] Do minor project cleaning --- .gitignore | 4 ---- distribution.gradle | 6 ------ 2 files changed, 10 deletions(-) diff --git a/.gitignore b/.gitignore index ba668b5..c5d0fce 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,6 @@ local.properties # Libraries /lib/ -# Zmod resources -/media/* -!/media/zmod/ - ### IntelliJ ### # Project file-based format diff --git a/distribution.gradle b/distribution.gradle index f3722c5..2751a01 100644 --- a/distribution.gradle +++ b/distribution.gradle @@ -71,15 +71,9 @@ tasks.register('pruneDistributionStage', Delete.class) { } } } - it.dependsOn(cleanDistributionStage) } distributions.main.contents { it.from stagePath it.includeEmptyDirs false } - -// All distribution tasks need to first stage files -[ distZip, distTar, assembleDist, installDist ].forEach { - it.dependsOn(stageDistribution) -} \ No newline at end of file From 578569ac0c385d70015140d771aee275dd5d60bc Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 1 Mar 2021 22:33:51 +0100 Subject: [PATCH 09/40] Write applyModTemplate task Resolves: #25 --- mod.gradle | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mod.gradle b/mod.gradle index e73aa4a..ef0f229 100644 --- a/mod.gradle +++ b/mod.gradle @@ -242,4 +242,13 @@ task createModStructure { project.mkdir(it) }) } -} \ No newline at end of file +} + +tasks.register('applyModTemplate', Copy.class) { + + it.description 'Apply Project Zomboid mod template.' + it.group 'mod' + + it.into projectDir + it.from 'docs/template' +} From 43ddb8edcadada986b67d45505e720698dfa1faa Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 1 Mar 2021 22:39:23 +0100 Subject: [PATCH 10/40] Apply mod template on initialization --- .idea/runConfigurations/initializeMod.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/.idea/runConfigurations/initializeMod.xml b/.idea/runConfigurations/initializeMod.xml index 930eef7..7eb4805 100644 --- a/.idea/runConfigurations/initializeMod.xml +++ b/.idea/runConfigurations/initializeMod.xml @@ -20,6 +20,7 @@