make gradle zip directory drop helper function nicer

This commit is contained in:
Adam 2022-05-21 12:44:51 +02:00
parent 9f48270a0a
commit 227ac27652
2 changed files with 8 additions and 3 deletions

View file

@ -74,5 +74,10 @@ fun Directory.filesChecksum() = asFileTree
/** Drop the first [count] directories from the path */
fun FileCopyDetails.dropDirectories(count: Int = 1): RelativePath =
fun FileCopyDetails.dropDirectories(count: Int): RelativePath =
RelativePath(true, *relativePath.segments.drop(count).toTypedArray())
/** Drop the first directory from the path */
fun FileCopyDetails.dropDirectory(): RelativePath =
dropDirectories(1)

View file

@ -1,7 +1,7 @@
import dev.adamko.kafkatorio.factoriomod.FactorioModPublishTask
import dev.adamko.kafkatorio.gradle.asConsumer
import dev.adamko.kafkatorio.gradle.asProvider
import dev.adamko.kafkatorio.gradle.dropDirectories
import dev.adamko.kafkatorio.gradle.dropDirectory
import dev.adamko.kafkatorio.gradle.factorioModAttributes
import dev.adamko.kafkatorio.gradle.typescriptAttributes
import dev.adamko.kafkatorio.task.TypescriptToLuaTask
@ -99,7 +99,7 @@ val installEventsTsSchema by tasks.registering(Sync::class) {
}
) {
// drop the first directory inside the zip
eachFile { relativePath = dropDirectories() }
eachFile { relativePath = dropDirectory() }
includeEmptyDirs = false
}
into(outputDir)