Set default value for download dir option of boostrap command

This commit is contained in:
Alexandre Archambault 2016-08-04 18:41:58 -04:00
parent c89dc684c1
commit c0f1ac8602
No known key found for this signature in database
GPG Key ID: 14640A6839C263A9
1 changed files with 19 additions and 13 deletions

View File

@ -16,11 +16,24 @@ case class Bootstrap(
import scala.collection.JavaConverters._
if (!options.standalone && options.downloadDir.isEmpty) {
Console.err.println(s"Error: no download dir specified. Specify one with -D or --download-dir")
Console.err.println("E.g. -D \"\\$HOME/.app-name/jars\"")
sys.exit(255)
}
val helper = new Helper(
options.common,
remainingArgs,
isolated = options.isolated,
warnBaseLoaderNotFound = false
)
lazy val downloadDir =
if (options.downloadDir.isEmpty)
helper.baseDependencies.headOption match {
case Some(dep) =>
s"\\$$HOME/.coursier/bootstrap/${dep.module.organization}/${dep.module.name}"
case None =>
Console.err.println("Error: no dependencies specified.")
sys.exit(255)
}
else
options.downloadDir
val (validProperties, wrongProperties) = options.property.partition(_.contains("="))
if (wrongProperties.nonEmpty) {
@ -68,13 +81,6 @@ case class Bootstrap(
}
val helper = new Helper(
options.common,
remainingArgs,
isolated = options.isolated,
warnBaseLoaderNotFound = false
)
val isolatedDeps = options.isolated.isolatedDeps(options.common.defaultArtifactType)
val (_, isolatedArtifactFiles) =
@ -181,7 +187,7 @@ case class Bootstrap(
val properties = new Properties
properties.setProperty("bootstrap.mainClass", mainClass)
if (!options.standalone)
properties.setProperty("bootstrap.jarDir", options.downloadDir)
properties.setProperty("bootstrap.jarDir", downloadDir)
outputZip.putNextEntry(propsEntry)
properties.store(outputZip, "")