mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -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.KobaltContext
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.archive.Archives
|
import com.beust.kobalt.archive.Archives
|
||||||
|
import com.beust.kobalt.archive.MetaArchive
|
||||||
import com.beust.kobalt.archive.Zip
|
import com.beust.kobalt.archive.Zip
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.aether.Scope
|
import com.beust.kobalt.maven.aether.Scope
|
||||||
|
@ -141,7 +142,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
||||||
val allFiles = includedFiles.flatMap { file ->
|
val allFiles = includedFiles.flatMap { file ->
|
||||||
file.allFromFiles(project.directory).map { file.from(it.path) }
|
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
|
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.
|
* Uses ZipArchiveOutputStream for fast inclusion of expanded jar files.
|
||||||
*/
|
*/
|
||||||
class MetaArchive(outputFile: File, val manifest: Manifest?) : Closeable {
|
class MetaArchive(outputFile: File, val manifest: Manifest?) : Closeable {
|
||||||
|
companion object {
|
||||||
|
val MANIFEST_MF = "/META-INF/MANIFEST.MF"
|
||||||
|
}
|
||||||
|
|
||||||
private val zos = ZipArchiveOutputStream(outputFile).apply {
|
private val zos = ZipArchiveOutputStream(outputFile).apply {
|
||||||
encoding = "UTF-8"
|
encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
|
@ -60,7 +64,7 @@ class MetaArchive(outputFile: File, val manifest: Manifest?) : Closeable {
|
||||||
manifest.write(fos)
|
manifest.write(fos)
|
||||||
}
|
}
|
||||||
|
|
||||||
val entry = zos.createArchiveEntry(manifestFile, "META-INF/MANIFEST.MF")
|
val entry = zos.createArchiveEntry(manifestFile, MetaArchive.MANIFEST_MF)
|
||||||
addEntry(entry, FileInputStream(manifestFile))
|
addEntry(entry, FileInputStream(manifestFile))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue