Skip to content

Commit

Permalink
Merge pull request #548 from mzuehlke/absAssemblyOutputPath
Browse files Browse the repository at this point in the history
Make `assemblyOutputPath` absolute
  • Loading branch information
eed3si9n authored Jan 3, 2025
2 parents 54da839 + 0b85bcc commit 9d35a4f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main/scala/sbtassembly/Assembly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -345,32 +345,33 @@ object Assembly {
.map(t => t - java.util.TimeZone.getDefault.getOffset(t))
.getOrElse(System.currentTimeMillis())

val absOutput = output.getAbsoluteFile
timed(Level.Debug, "Create jar") {
if (output.isDirectory) {
val invalidPath = output.toPath.toAbsolutePath.normalize
if (absOutput.isDirectory) {
val invalidPath = absOutput.toPath.normalize
log.error(s"expected a file name for assemblyOutputPath, but found a directory: ${invalidPath}; fix the setting or delete the directory")
throw new RuntimeException("Exiting task")
} else {
IO.delete(output)
val dest = output.getParentFile
IO.delete(absOutput)
val dest = absOutput.getParentFile
if (!dest.exists()) {
dest.mkdirs()
}
createJar(output, jarEntriesToWrite, jarManifest, localTime)
createJar(absOutput, jarEntriesToWrite, jarManifest, localTime)
}
}
val fullSha1 = timed(Level.Debug, "Hash newly-built Jar") {
hash(output)
hash(absOutput)
}
val builtAssemblyJar =
if (ao.appendContentHash) {
val sha1 = ao.maxHashLength.fold(fullSha1)(length => fullSha1.take(length))
val newName = output.getName.replaceAll("\\.[^.]*$", "") + "-" + sha1 + ".jar"
val outputWithHash = new File(output.getParentFile, newName)
val newName = absOutput.getName.replaceAll("\\.[^.]*$", "") + "-" + sha1 + ".jar"
val outputWithHash = new File(absOutput.getParentFile, newName)
IO.delete(outputWithHash)
Files.move(output.toPath, outputWithHash.toPath, StandardCopyOption.REPLACE_EXISTING)
Files.move(absOutput.toPath, outputWithHash.toPath, StandardCopyOption.REPLACE_EXISTING)
outputWithHash
} else output
} else absOutput
ao.prependShellScript
.foreach { shellScript =>
timed(Level.Info, "Prepend shell script") {
Expand Down

0 comments on commit 9d35a4f

Please sign in to comment.