mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 16:07:12 -07:00
Introducing the copy() directive for installation.
Example use: install { collect(compileDependencies).map { copy(it, to("deploy")) } }
This commit is contained in:
parent
756fbec648
commit
9514d80b99
3 changed files with 17 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.beust.kobalt
|
package com.beust.kobalt
|
||||||
|
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base classes for directives that support install(from,to) (e.g. install{} or jar{}).
|
* Base classes for directives that support install(from,to) (e.g. install{} or jar{}).
|
||||||
|
@ -18,6 +19,13 @@ open class IncludeFromTo {
|
||||||
@Directive
|
@Directive
|
||||||
fun to(s: String) = To(s)
|
fun to(s: String) = To(s)
|
||||||
|
|
||||||
|
@Directive
|
||||||
|
fun copy(from: String, to: To) {
|
||||||
|
with(File(from)) {
|
||||||
|
includedFiles.add(IncludedFile(from(parent), to, listOf(IFileSpec.FileSpec(name))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun include(vararg files: String) {
|
fun include(vararg files: String) {
|
||||||
includedFiles.add(IncludedFile(files.map { IFileSpec.FileSpec(it) }))
|
includedFiles.add(IncludedFile(files.map { IFileSpec.FileSpec(it) }))
|
||||||
|
|
|
@ -333,7 +333,13 @@ class KFiles {
|
||||||
val result = includedFiles.fold(arrayListOf<File>()) { files, includedFile: IncludedFile ->
|
val result = includedFiles.fold(arrayListOf<File>()) { files, includedFile: IncludedFile ->
|
||||||
val foundFiles = includedFile.allFromFiles(project.directory)
|
val foundFiles = includedFile.allFromFiles(project.directory)
|
||||||
val absFiles = foundFiles.map {
|
val absFiles = foundFiles.map {
|
||||||
File(KFiles.joinDir(project.directory, includedFile.from, it.path))
|
if (it.isAbsolute) {
|
||||||
|
it
|
||||||
|
} else if (File(includedFile.from).isAbsolute) {
|
||||||
|
File(includedFile.from, it.path)
|
||||||
|
} else {
|
||||||
|
File(KFiles.joinDir(project.directory, includedFile.from, it.path))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
files.addAll(absFiles)
|
files.addAll(absFiles)
|
||||||
files
|
files
|
||||||
|
|
|
@ -223,9 +223,10 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
config.includedFiles.forEach { inf ->
|
config.includedFiles.forEach { inf ->
|
||||||
val target = inf.to
|
val target = inf.to
|
||||||
val targetFile = File(target)
|
val targetFile = File(target)
|
||||||
|
val files = KFiles.materializeIncludedFiles(project, listOf(inf))
|
||||||
|
context.logger.log(project.name, 2, " Deleting target dir $targetFile")
|
||||||
targetFile.deleteRecursively()
|
targetFile.deleteRecursively()
|
||||||
targetFile.mkdirs()
|
targetFile.mkdirs()
|
||||||
val files = KFiles.materializeIncludedFiles(project, listOf(inf))
|
|
||||||
files.forEach {
|
files.forEach {
|
||||||
context.logger.log(project.name, 1, " Installing $it to $targetFile")
|
context.logger.log(project.name, 1, " Installing $it to $targetFile")
|
||||||
KFiles.copyRecursively(it, targetFile, true)
|
KFiles.copyRecursively(it, targetFile, true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue