From f1f71debb4171794b9f8ac53b717756b6d07e946 Mon Sep 17 00:00:00 2001 From: Logan Lang <95497005+devloglogan@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:46:49 -0700 Subject: [PATCH] Add gradle tasks related to zipping sample projects (#215) --- .gitignore | 1 + build.gradle | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/.gitignore b/.gitignore index d36d82b2..55182b22 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ local.properties # Misc .DS_Store /plugin/src/gen/ +/zippedSamples diff --git a/build.gradle b/build.gradle index f7038f59..2858ea4b 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ task clean(type: Delete) { dependsOn 'cleanAddon' dependsOn 'cleanBuildFromSamples' + dependsOn 'cleanZippedSamples' dependsOn ':plugin:clean' } @@ -149,3 +150,37 @@ task cleanBuildFromSamples { } } } + +task zipSamples { + def samplesDir = file 'samples' + def directoriesToZip = samplesDir.listFiles().findAll { it.isDirectory() && it.name != 'builds' } + + def destinationDir = file 'zippedSamples' + destinationDir.mkdirs() + + directoriesToZip.each { dir -> + def godotFolder = new File(dir, '.godot') + if (godotFolder.exists()) { + godotFolder.deleteDir() + } + + def androidFolder = new File(dir, 'android') + if (androidFolder.exists()) { + androidFolder.deleteDir() + } + + def zipTask = tasks.create(name: "zip${dir.name.capitalize()}", type: Zip) { + from(dir.parentFile) { + include "${dir.name}/**" + } + archiveFileName = "${dir.name}.zip" + destinationDirectory = destinationDir + } + + dependsOn zipTask + } +} + +task cleanZippedSamples { + delete 'zippedSamples' +} \ No newline at end of file