1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-25 16:07:12 -07:00

Fix copy().

Fixes https://github.com/cbeust/kobalt/issues/387
This commit is contained in:
Cedric Beust 2017-04-06 09:39:21 -07:00
parent 94400756ff
commit 38d2187eae
2 changed files with 11 additions and 8 deletions

View file

@ -21,9 +21,8 @@ open class IncludeFromTo {
@Directive
fun copy(from: From, to: To) {
with(File(from.path)) {
includedFiles.add(IncludedFile(from, to, listOf(IFileSpec.FileSpec(name))))
}
val dir = File(from.path).parentFile
includedFiles.add(IncludedFile(from(dir.absolutePath), to, listOf(IFileSpec.FileSpec(from.path))))
}
@Directive

View file

@ -220,13 +220,17 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
val toDir = KFiles.makeDir(config.target)
File(buildDir).copyRecursively(toDir, overwrite = true)
} else {
config.includedFiles.forEach { inf ->
val target = inf.to
val targetFile = File(target)
val files = KFiles.materializeIncludedFiles(project, listOf(inf))
// Delete all target directories
val targetDirs = config.includedFiles.map { File(it.to) }.distinct().forEach { targetFile ->
val isFile = targetFile.isFile
context.logger.log(project.name, 2, " Deleting target dir $targetFile")
targetFile.deleteRecursively()
targetFile.mkdirs()
if (! isFile) targetFile.mkdirs()
}
// Perform the installations
config.includedFiles.forEach { inf ->
val targetFile = File(inf.to)
val files = KFiles.materializeIncludedFiles(project, listOf(inf))
files.forEach {
context.logger.log(project.name, 1, " Installing $it to $targetFile")
KFiles.copyRecursively(it, targetFile, true)