mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
Refactor.
This commit is contained in:
parent
9b08f57917
commit
6cab82e280
2 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,7 @@ package com.beust.kobalt
|
|||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.archive.Archives
|
||||
import com.beust.kobalt.archive.MetaArchive
|
||||
import com.beust.kobalt.archive.Zip
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.aether.Scope
|
||||
|
@ -141,7 +142,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
|||
val allFiles = includedFiles.flatMap { file ->
|
||||
file.allFromFiles(project.directory).map { file.from(it.path) }
|
||||
}
|
||||
val manifestFiles = allFiles.filter { it.path.contains("META-INF/MANIFEST.MF") }
|
||||
val manifestFiles = allFiles.filter { it.path.contains(MetaArchive.MANIFEST_MF) }
|
||||
return if (manifestFiles.any()) manifestFiles[0] else null
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@ import org.apache.commons.compress.archivers.zip.ZipFile as ApacheZipFile
|
|||
* Uses ZipArchiveOutputStream for fast inclusion of expanded jar files.
|
||||
*/
|
||||
class MetaArchive(outputFile: File, val manifest: Manifest?) : Closeable {
|
||||
companion object {
|
||||
val MANIFEST_MF = "/META-INF/MANIFEST.MF"
|
||||
}
|
||||
|
||||
private val zos = ZipArchiveOutputStream(outputFile).apply {
|
||||
encoding = "UTF-8"
|
||||
}
|
||||
|
@ -60,7 +64,7 @@ class MetaArchive(outputFile: File, val manifest: Manifest?) : Closeable {
|
|||
manifest.write(fos)
|
||||
}
|
||||
|
||||
val entry = zos.createArchiveEntry(manifestFile, "META-INF/MANIFEST.MF")
|
||||
val entry = zos.createArchiveEntry(manifestFile, MetaArchive.MANIFEST_MF)
|
||||
addEntry(entry, FileInputStream(manifestFile))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue