mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 16:07:12 -07:00
Merge pull request #239 from DevCharly/fatjar-classes-fix
fixed fatJar for projects in subdirectories that depend on other projects
This commit is contained in:
commit
b9924d3b69
3 changed files with 17 additions and 23 deletions
|
@ -107,7 +107,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
|||
if (! seen.contains(file.path)) {
|
||||
seen.add(file.path)
|
||||
if (! KFiles.Companion.isExcluded(file, jar.excludes)) {
|
||||
result.add(IncludedFile(specs = arrayListOf(IFileSpec.FileSpec(file.path)),
|
||||
result.add(IncludedFile(specs = arrayListOf(IFileSpec.FileSpec(file.absolutePath)),
|
||||
expandJarFiles = true))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,19 @@ class Archives {
|
|||
val result = File(archiveDir.path, fullArchiveName)
|
||||
log(3, "Creating $result")
|
||||
if (! Features.USE_TIMESTAMPS || isOutdated(project.directory, includedFiles, result)) {
|
||||
val outStream = outputStreamFactory(FileOutputStream(result))
|
||||
JarUtils.addFiles(project.directory, includedFiles, outStream, expandJarFiles)
|
||||
log(2, text = "Added ${includedFiles.size} files to $result")
|
||||
outStream.flush()
|
||||
outStream.close()
|
||||
log(1, " Created $result")
|
||||
try {
|
||||
outputStreamFactory(FileOutputStream(result)).use {
|
||||
JarUtils.addFiles(project.directory, includedFiles, it, expandJarFiles)
|
||||
log(2, text = "Added ${includedFiles.size} files to $result")
|
||||
log(1, " Created $result")
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
// make sure that incomplete archive is deleted
|
||||
// otherwise incremental build does not work on next run
|
||||
result.delete()
|
||||
throw e
|
||||
}
|
||||
|
||||
} else {
|
||||
log(3, " $result is up to date")
|
||||
}
|
||||
|
|
|
@ -47,25 +47,12 @@ public class JarUtils {
|
|||
throw AssertionError("File should exist: $localFile")
|
||||
}
|
||||
|
||||
if (foundFile.isDirectory) {
|
||||
if (localFile.isDirectory) {
|
||||
log(2, "Writing contents of directory $foundFile")
|
||||
|
||||
// Directory
|
||||
var name = foundFile.name
|
||||
if (!name.isEmpty()) {
|
||||
if (!name.endsWith("/")) name += "/"
|
||||
val entry = JarEntry(name)
|
||||
entry.time = localFile.lastModified()
|
||||
try {
|
||||
outputStream.putNextEntry(entry)
|
||||
} catch(ex: ZipException) {
|
||||
log(2, "Can't add $name: ${ex.message}")
|
||||
} finally {
|
||||
outputStream.closeEntry()
|
||||
}
|
||||
}
|
||||
val includedFile = IncludedFile(From(foundFile.path), To(""), listOf(IFileSpec.GlobSpec("**")))
|
||||
addSingleFile(".", includedFile, outputStream, expandJarFiles)
|
||||
val includedFile = IncludedFile(From(""), To(""), listOf(IFileSpec.GlobSpec("**")))
|
||||
addSingleFile(localFile.path, includedFile, outputStream, expandJarFiles)
|
||||
} else {
|
||||
if (file.expandJarFiles && foundFile.name.endsWith(".jar") && ! file.from.contains("resources")) {
|
||||
log(2, "Writing contents of jar file $foundFile")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue