mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
delete jar if exception occurs while creating it (otherwise incremental build does not work on next run)
This commit is contained in:
parent
cbbe9cbeb7
commit
d3a70a25a8
1 changed files with 13 additions and 6 deletions
|
@ -33,12 +33,19 @@ class Archives {
|
||||||
val result = File(archiveDir.path, fullArchiveName)
|
val result = File(archiveDir.path, fullArchiveName)
|
||||||
log(3, "Creating $result")
|
log(3, "Creating $result")
|
||||||
if (! Features.USE_TIMESTAMPS || isOutdated(project.directory, includedFiles, result)) {
|
if (! Features.USE_TIMESTAMPS || isOutdated(project.directory, includedFiles, result)) {
|
||||||
val outStream = outputStreamFactory(FileOutputStream(result))
|
try {
|
||||||
JarUtils.addFiles(project.directory, includedFiles, outStream, expandJarFiles)
|
outputStreamFactory(FileOutputStream(result)).use {
|
||||||
log(2, text = "Added ${includedFiles.size} files to $result")
|
JarUtils.addFiles(project.directory, includedFiles, it, expandJarFiles)
|
||||||
outStream.flush()
|
log(2, text = "Added ${includedFiles.size} files to $result")
|
||||||
outStream.close()
|
log(1, " Created $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 {
|
} else {
|
||||||
log(3, " $result is up to date")
|
log(3, " $result is up to date")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue