mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -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
|
@ -11,7 +11,9 @@ import com.beust.kobalt.internal.IncrementalManager
|
|||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||
import com.beust.kobalt.internal.ParallelLogger
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.Md5
|
||||
import com.beust.kobalt.maven.PomGenerator
|
||||
import com.beust.kobalt.misc.IncludedFile
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import java.io.File
|
||||
|
@ -68,6 +70,34 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
|||
* skipped.
|
||||
*/
|
||||
override fun assemble(project: Project, context: KobaltContext) : IncrementalTaskInfo {
|
||||
val allArchivers = packages.filter { it.project.name == project.name }
|
||||
|
||||
if (false) {
|
||||
// Work in progress
|
||||
val allIncludedFiles = arrayListOf<IncludedFile>()
|
||||
val zipToFiles = hashMapOf<String, List<IncludedFile>>()
|
||||
allArchivers.forEach { packageConfig ->
|
||||
listOf(packageConfig.jars, packageConfig.wars, packageConfig.zips).forEach { archives ->
|
||||
archives.forEach {
|
||||
val files = jarGenerator.findIncludedFiles(packageConfig.project, context, it)
|
||||
allIncludedFiles.addAll(files)
|
||||
zipToFiles[it.name] = files
|
||||
}
|
||||
}
|
||||
}
|
||||
val allFiles = allIncludedFiles.fold(arrayListOf<File>()) { files, includedFile: IncludedFile ->
|
||||
val foundFiles = includedFile.allFromFiles(project.directory)
|
||||
val absFiles = foundFiles.map {
|
||||
File(KFiles.joinDir(project.directory, includedFile.from, it.path))
|
||||
}
|
||||
files.addAll(absFiles)
|
||||
files
|
||||
}
|
||||
|
||||
val md5 = Md5.toMd5Directories(allFiles)
|
||||
println("MD5 is: " + md5)
|
||||
}
|
||||
|
||||
return IncrementalTaskInfo(
|
||||
{ null },
|
||||
{ null },
|
||||
|
@ -75,7 +105,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
|||
try {
|
||||
project.projectProperties.put(Archives.JAR_NAME,
|
||||
context.variant.archiveName(project, null, ".jar"))
|
||||
packages.filter { it.project.name == project.name }.forEach { packageConfig ->
|
||||
allArchivers.forEach { packageConfig ->
|
||||
packageConfig.jars.forEach { jarGenerator.generateJar(packageConfig.project, context, it) }
|
||||
packageConfig.wars.forEach { warGenerator.generateWar(packageConfig.project, context, it) }
|
||||
packageConfig.zips.forEach { zipGenerator.generateZip(packageConfig.project, context, it) }
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.beust.kobalt.api.KobaltContext
|
|||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.archive.Archives
|
||||
import com.beust.kobalt.archive.War
|
||||
import com.beust.kobalt.archive.Zip
|
||||
import com.beust.kobalt.internal.ParallelLogger
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.misc.From
|
||||
|
@ -19,7 +20,8 @@ import java.io.OutputStream
|
|||
import java.nio.file.Paths
|
||||
import java.util.jar.JarOutputStream
|
||||
|
||||
class WarGenerator @Inject constructor(val dependencyManager: DependencyManager, val kobaltLog: ParallelLogger) {
|
||||
class WarGenerator @Inject constructor(val dependencyManager: DependencyManager, val kobaltLog: ParallelLogger)
|
||||
: ArchiveFileFinder {
|
||||
|
||||
companion object {
|
||||
val WEB_INF = "WEB-INF"
|
||||
|
@ -27,7 +29,7 @@ class WarGenerator @Inject constructor(val dependencyManager: DependencyManager,
|
|||
val LIB = "$WEB_INF/lib"
|
||||
}
|
||||
|
||||
fun findIncludedFiles(project: Project, context: KobaltContext, war: War) : List<IncludedFile> {
|
||||
override fun findIncludedFiles(project: Project, context: KobaltContext, war: Zip) : List<IncludedFile> {
|
||||
//
|
||||
// src/main/web app and classes
|
||||
//
|
||||
|
|
|
@ -7,11 +7,17 @@ import com.beust.kobalt.archive.Archives
|
|||
import com.beust.kobalt.archive.Zip
|
||||
import com.beust.kobalt.internal.ParallelLogger
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.misc.IncludedFile
|
||||
import com.google.inject.Inject
|
||||
|
||||
class ZipGenerator @Inject constructor(val dependencyManager: DependencyManager, val kobaltLog: ParallelLogger) {
|
||||
class ZipGenerator @Inject constructor(val dependencyManager: DependencyManager, val kobaltLog: ParallelLogger)
|
||||
: ArchiveFileFinder {
|
||||
override fun findIncludedFiles(project: Project, context: KobaltContext, zip: Zip): List<IncludedFile> {
|
||||
return JarGenerator.findIncludedFiles(project.directory, zip.includedFiles, zip.excludes)
|
||||
}
|
||||
|
||||
fun generateZip(project: Project, context: KobaltContext, zip: Zip) {
|
||||
val allFiles = JarGenerator.findIncludedFiles(project.directory, zip.includedFiles, zip.excludes)
|
||||
val allFiles = findIncludedFiles(project, context, zip)
|
||||
Archives.generateArchive(project, context, zip.name, ".zip", allFiles)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue