1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Fix packaging.

This commit is contained in:
Cedric Beust 2015-11-15 22:11:32 -08:00
parent 1590128a11
commit 3d3cdfdc3f
2 changed files with 30 additions and 17 deletions

View file

@ -34,18 +34,22 @@ public class JarUtils {
val path = spec.toString()
spec.toFiles(directory + "/" + file.from).forEach { source ->
if (source.isDirectory) {
log(2, "Writing contents of directory ${source}")
// Directory
var name = path
if (!name.isEmpty()) {
if (!name.endsWith("/")) name += "/"
val entry = JarEntry(name)
entry.time = source.lastModified()
outputStream.putNextEntry(entry)
outputStream.closeEntry()
try {
outputStream.putNextEntry(entry)
} finally {
outputStream.closeEntry()
}
}
val fileSpecs: List<IFileSpec> = source.listFiles().map { IFileSpec.FileSpec(it.name) }
val subFiles = IncludedFile(From(file.from), To(file.to), fileSpecs)
addSingleFile(directory, subFiles, outputStream, expandJarFiles)
val includedFile = IncludedFile(From(source.path), To(""), listOf(IFileSpec.Glob("**")))
addSingleFile(directory, includedFile, outputStream, expandJarFiles)
} else {
if (expandJarFiles and source.name.endsWith(".jar")) {
log(2, "Writing contents of jar file ${source}")

View file

@ -4,16 +4,14 @@ import com.beust.kobalt.IFileSpec
import com.beust.kobalt.IFileSpec.FileSpec
import com.beust.kobalt.IFileSpec.Glob
import com.beust.kobalt.TaskResult
import com.beust.kobalt.api.ConfigPlugin
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.KobaltContext
import com.beust.kobalt.api.Project
import com.beust.kobalt.api.*
import com.beust.kobalt.api.annotation.Directive
import com.beust.kobalt.api.annotation.ExportedProjectProperty
import com.beust.kobalt.api.annotation.Task
import com.beust.kobalt.glob
import com.beust.kobalt.internal.JvmCompilerPlugin
import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.maven.IClasspathDependency
import com.beust.kobalt.maven.LocalRepo
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors
@ -161,14 +159,25 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
if (jar.fatJar) {
log(2, "Creating fat jar")
listOf(dependencyManager.transitiveClosure(project.compileDependencies),
dependencyManager.transitiveClosure(project.compileRuntimeDependencies)).forEach { dep ->
dep.map { it.jarFile.get() }.forEach {
if (!isExcluded(it, jar.excludes)) {
allFiles.add(IncludedFile(arrayListOf(FileSpec(it.path))))
}
}
}
val seen = hashSetOf<String>()
val dependentProjects = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS)
as List<ProjectDescription>
listOf(dependencyManager.calculateDependencies(project, context, dependentProjects,
project.compileDependencies),
dependencyManager.calculateDependencies(project, context, dependentProjects,
project.compileRuntimeDependencies))
.forEach { deps : List<IClasspathDependency> ->
deps.map {
it.jarFile.get()
}.forEach { file : File ->
if (! seen.contains(file.name)) {
seen.add(file.name)
if (!isExcluded(file, jar.excludes)) {
allFiles.add(IncludedFile(arrayListOf(FileSpec(file.path))))
}
}
}
}
}
//