mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Work in progress for incremental archival task.
This commit is contained in:
parent
c056fa5c9f
commit
383128d96b
7 changed files with 65 additions and 12 deletions
|
@ -0,0 +1,11 @@
|
|||
package com.beust.kobalt.plugin.packaging
|
||||
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.archive.Zip
|
||||
import com.beust.kobalt.misc.IncludedFile
|
||||
|
||||
interface ArchiveFileFinder {
|
||||
fun findIncludedFiles(project: Project, context: KobaltContext, zip: Zip) : List<IncludedFile>
|
||||
}
|
||||
|
|
@ -4,9 +4,11 @@ import com.beust.kobalt.api.KobaltContext
|
|||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.archive.Archives
|
||||
import com.beust.kobalt.archive.Jar
|
||||
import com.beust.kobalt.archive.Zip
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.aether.Scope
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.beust.kobalt.plugin.packaging.ArchiveFileFinder
|
||||
import com.google.inject.Inject
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
@ -15,9 +17,10 @@ import java.nio.file.Paths
|
|||
import java.util.jar.JarOutputStream
|
||||
import java.util.jar.Manifest
|
||||
|
||||
class JarGenerator @Inject constructor(val dependencyManager: DependencyManager) {
|
||||
class JarGenerator @Inject constructor(val dependencyManager: DependencyManager) : ArchiveFileFinder {
|
||||
companion object {
|
||||
fun findIncludedFiles(directory: String, files: List<IncludedFile>, excludes: List<Glob>)
|
||||
fun findIncludedFiles(directory: String, files: List<IncludedFile>, excludes: List<Glob>,
|
||||
throwOnError: Boolean = true)
|
||||
: List<IncludedFile> {
|
||||
val result = arrayListOf<IncludedFile>()
|
||||
files.forEach { includedFile ->
|
||||
|
@ -27,7 +30,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
|||
if (File(directory, fromPath).exists()) {
|
||||
spec.toFiles(directory, fromPath).forEach { file ->
|
||||
val fullFile = File(KFiles.joinDir(directory, fromPath, file.path))
|
||||
if (! fullFile.exists()) {
|
||||
if (! fullFile.exists() && throwOnError) {
|
||||
throw AssertionError("File should exist: $fullFile")
|
||||
}
|
||||
|
||||
|
@ -52,7 +55,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
|||
}
|
||||
}
|
||||
|
||||
fun findIncludedFiles(project: Project, context: KobaltContext, jar: Jar) : List<IncludedFile> {
|
||||
override fun findIncludedFiles(project: Project, context: KobaltContext, jar: Zip) : List<IncludedFile> {
|
||||
//
|
||||
// Add all the applicable files for the current project
|
||||
//
|
||||
|
@ -86,7 +89,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
|||
//
|
||||
// The user specified an include, just use it verbatim
|
||||
//
|
||||
val includedFiles = findIncludedFiles(project.directory, jar.includedFiles, jar.excludes)
|
||||
val includedFiles = findIncludedFiles(project.directory, jar.includedFiles, jar.excludes, false)
|
||||
result.addAll(includedFiles)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.beust.kobalt.api.annotation.Directive
|
|||
*/
|
||||
open class Jar(override val project: Project,
|
||||
override var name : String = Archives.defaultArchiveName(project) + ".jar",
|
||||
var fatJar: Boolean = false) : Zip(project, name), AttributeHolder {
|
||||
override var fatJar: Boolean = false) : Zip(project, name, fatJar), AttributeHolder {
|
||||
@Directive
|
||||
fun manifest(init: Manifest.(p: Manifest) -> Unit) : Manifest {
|
||||
val m = Manifest(this)
|
||||
|
|
|
@ -8,7 +8,8 @@ import com.beust.kobalt.misc.From
|
|||
import com.beust.kobalt.misc.IncludedFile
|
||||
import com.beust.kobalt.misc.To
|
||||
|
||||
open class Zip(open val project: Project, open var name: String = Archives.defaultArchiveName(project) + ".zip") {
|
||||
open class Zip(open val project: Project, open var name: String = Archives.defaultArchiveName(project) + ".zip",
|
||||
open var fatJar: Boolean = false) {
|
||||
val excludes = arrayListOf<Glob>()
|
||||
|
||||
@Directive
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue