mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix packaging.
This commit is contained in:
parent
1590128a11
commit
3d3cdfdc3f
2 changed files with 30 additions and 17 deletions
|
@ -34,18 +34,22 @@ public class JarUtils {
|
||||||
val path = spec.toString()
|
val path = spec.toString()
|
||||||
spec.toFiles(directory + "/" + file.from).forEach { source ->
|
spec.toFiles(directory + "/" + file.from).forEach { source ->
|
||||||
if (source.isDirectory) {
|
if (source.isDirectory) {
|
||||||
|
log(2, "Writing contents of directory ${source}")
|
||||||
|
|
||||||
// Directory
|
// Directory
|
||||||
var name = path
|
var name = path
|
||||||
if (!name.isEmpty()) {
|
if (!name.isEmpty()) {
|
||||||
if (!name.endsWith("/")) name += "/"
|
if (!name.endsWith("/")) name += "/"
|
||||||
val entry = JarEntry(name)
|
val entry = JarEntry(name)
|
||||||
entry.time = source.lastModified()
|
entry.time = source.lastModified()
|
||||||
outputStream.putNextEntry(entry)
|
try {
|
||||||
outputStream.closeEntry()
|
outputStream.putNextEntry(entry)
|
||||||
|
} finally {
|
||||||
|
outputStream.closeEntry()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val fileSpecs: List<IFileSpec> = source.listFiles().map { IFileSpec.FileSpec(it.name) }
|
val includedFile = IncludedFile(From(source.path), To(""), listOf(IFileSpec.Glob("**")))
|
||||||
val subFiles = IncludedFile(From(file.from), To(file.to), fileSpecs)
|
addSingleFile(directory, includedFile, outputStream, expandJarFiles)
|
||||||
addSingleFile(directory, subFiles, outputStream, expandJarFiles)
|
|
||||||
} else {
|
} else {
|
||||||
if (expandJarFiles and source.name.endsWith(".jar")) {
|
if (expandJarFiles and source.name.endsWith(".jar")) {
|
||||||
log(2, "Writing contents of jar file ${source}")
|
log(2, "Writing contents of jar file ${source}")
|
||||||
|
|
|
@ -4,16 +4,14 @@ import com.beust.kobalt.IFileSpec
|
||||||
import com.beust.kobalt.IFileSpec.FileSpec
|
import com.beust.kobalt.IFileSpec.FileSpec
|
||||||
import com.beust.kobalt.IFileSpec.Glob
|
import com.beust.kobalt.IFileSpec.Glob
|
||||||
import com.beust.kobalt.TaskResult
|
import com.beust.kobalt.TaskResult
|
||||||
import com.beust.kobalt.api.ConfigPlugin
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.Kobalt
|
|
||||||
import com.beust.kobalt.api.KobaltContext
|
|
||||||
import com.beust.kobalt.api.Project
|
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
||||||
import com.beust.kobalt.api.annotation.Task
|
import com.beust.kobalt.api.annotation.Task
|
||||||
import com.beust.kobalt.glob
|
import com.beust.kobalt.glob
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
|
import com.beust.kobalt.maven.IClasspathDependency
|
||||||
import com.beust.kobalt.maven.LocalRepo
|
import com.beust.kobalt.maven.LocalRepo
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
|
@ -161,14 +159,25 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
if (jar.fatJar) {
|
if (jar.fatJar) {
|
||||||
log(2, "Creating fat jar")
|
log(2, "Creating fat jar")
|
||||||
|
|
||||||
listOf(dependencyManager.transitiveClosure(project.compileDependencies),
|
val seen = hashSetOf<String>()
|
||||||
dependencyManager.transitiveClosure(project.compileRuntimeDependencies)).forEach { dep ->
|
val dependentProjects = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS)
|
||||||
dep.map { it.jarFile.get() }.forEach {
|
as List<ProjectDescription>
|
||||||
if (!isExcluded(it, jar.excludes)) {
|
listOf(dependencyManager.calculateDependencies(project, context, dependentProjects,
|
||||||
allFiles.add(IncludedFile(arrayListOf(FileSpec(it.path))))
|
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))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue