Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure directories are created recursively when the package sub-command is called #1371

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/cli/src/main/scala/scala/cli/commands/Package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -304,20 +304,20 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
val content = Library.libraryJar(build)
alreadyExistsCheck()
if (force) os.write.over(destPath, content)
else os.write(destPath, content)
else os.write(destPath, content, createFolders = true)
destPath
case PackageType.SourceJar =>
val now = System.currentTimeMillis()
val content = sourceJar(build, now)
alreadyExistsCheck()
if (force) os.write.over(destPath, content)
else os.write(destPath, content)
if (force) os.write.over(destPath, content, createFolders = true)
else os.write(destPath, content, createFolders = true)
destPath
case PackageType.DocJar =>
val docJarPath = value(docJar(build, logger, extraArgs))
alreadyExistsCheck()
if (force) os.copy.over(docJarPath, destPath)
else os.copy(docJarPath, destPath)
if (force) os.copy.over(docJarPath, destPath, createFolders = true)
else os.copy(docJarPath, destPath, createFolders = true)
destPath
case a: PackageType.Assembly =>
value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object ProcUtil {
content.drop("#!/bin/sh".length)
else
sys.error("Can't happen")
os.write.over(file, updatedContent)
os.write.over(file, updatedContent, createFolders = true)
}

usesSh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,24 @@ abstract class PackageTestDefinitions(val scalaVersionOpt: Option[String])
}
}

test("ensure directories are created recursively when packaging a jar") {
TestInputs(
os.rel / "Simple.scala" -> s"""object Simple extends App { println() }"""
).fromRoot { (root: os.Path) =>
val jarPath =
os.rel / "out" / "inner-out" / "Simple.jar" // the `out` directory doesn't exist and should be created
os.proc(
TestUtil.cli,
"package",
".",
"--library",
"-o",
jarPath,
extraOptions
).call(cwd = root)
}
}

def javaOptionsDockerTest(): Unit = {
val fileName = "Hello.scala"
val imageName = "hello"
Expand Down