Merge pull request #173 from alexarchambault/topic/better-launcher

Better launcher
This commit is contained in:
Alexandre Archambault 2016-02-24 23:44:56 +01:00
commit ace156e2de
6 changed files with 38 additions and 20 deletions

View File

@ -217,6 +217,8 @@ public class Bootstrap {
});
}
String clearLine = "\033[2K";
try {
while (localURLs.size() < urls.size()) {
Future<URL> future = completionService.take();
@ -224,7 +226,6 @@ public class Bootstrap {
URL url = future.get();
localURLs.add(url);
int nowMissing = urls.size() - localURLs.size();
String clearLine = "\033[2K";
String up = "\033[1A";
System.err.print(clearLine + "Downloaded " + (missingURLs.size() - nowMissing) + " missing file(s) / " + missingURLs.size() + "\n" + up);
} catch (ExecutionException ex) {
@ -236,6 +237,8 @@ public class Bootstrap {
exit("Interrupted");
}
System.err.print(clearLine);
return localURLs;
}

View File

@ -375,6 +375,10 @@ case class Bootstrap(
@Value("key=value")
@Short("P")
property: List[String],
@Help("Set Java command-line options in the generated launcher.")
@Value("option")
@Short("J")
javaOpt: List[String],
@Recurse
isolated: IsolatedLoaderOptions,
@Recurse
@ -475,7 +479,7 @@ case class Bootstrap(
)
else
(
helper.res.artifacts.map(_.url),
helper.artifacts(sources = false, javadoc = false).map(_.url),
Seq.empty[File]
)
@ -552,10 +556,10 @@ case class Bootstrap(
outputZip.close()
// escaping of javaOpt possibly a bit loose :-|
val shellPreamble = Seq(
"#!/usr/bin/env sh",
"exec java -jar \"$0\" \"$@\""
"exec java -jar " + javaOpt.map(s => "'" + s.replace("'", "\\'") + "'").mkString(" ") + " \"$0\" \"$@\""
).mkString("", "\n", "\n")
try NIOFiles.write(output0.toPath, shellPreamble.getBytes("UTF-8") ++ buffer.toByteArray)

View File

@ -283,11 +283,11 @@ class Helper(
sys.exit(1)
}
def fetch(
def artifacts(
sources: Boolean,
javadoc: Boolean,
subset: Set[Dependency] = null
): Seq[File] = {
): Seq[Artifact] = {
if (subset == null && verbose0 >= 0) {
val msg = cachePolicies match {
@ -302,17 +302,25 @@ class Helper(
val res0 = Option(subset).fold(res)(res.subset)
val artifacts =
if (classifier0.nonEmpty || sources || javadoc) {
var classifiers = classifier0
if (sources)
classifiers = classifiers :+ "sources"
if (javadoc)
classifiers = classifiers :+ "javadoc"
if (classifier0.nonEmpty || sources || javadoc) {
var classifiers = classifier0
if (sources)
classifiers = classifiers :+ "sources"
if (javadoc)
classifiers = classifiers :+ "javadoc"
res0.classifiersArtifacts(classifiers.distinct)
} else
res0.artifacts
res0.classifiersArtifacts(classifiers.distinct)
} else
res0.artifacts
}
def fetch(
sources: Boolean,
javadoc: Boolean,
subset: Set[Dependency] = null
): Seq[File] = {
val artifacts0 = artifacts(sources, javadoc, subset)
val logger =
if (verbose0 >= 0)
@ -320,10 +328,10 @@ class Helper(
else
None
if (verbose0 >= 1 && artifacts.nonEmpty)
println(s" Found ${artifacts.length} artifacts")
if (verbose0 >= 1 && artifacts0.nonEmpty)
println(s" Found ${artifacts0.length} artifacts")
val tasks = artifacts.map(artifact =>
val tasks = artifacts0.map(artifact =>
(Cache.file(artifact, caches, cachePolicies.head, checksums = checksums, logger = logger, pool = pool) /: cachePolicies.tail)(
_ orElse Cache.file(artifact, caches, _, checksums = checksums, logger = logger, pool = pool)
).run.map(artifact.->)

BIN
coursier

Binary file not shown.

View File

@ -11,6 +11,9 @@ fi
"$SBTPACK_LAUNCHER" bootstrap \
com.github.alexarchambault:coursier-cli_2.11:$VERSION \
--classifier standalone \
--intransitive \
-J "-noverify" \
--no-default \
-r central \
-r sonatype:releases \

View File

@ -3,6 +3,6 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.1.0")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.0")
addSbtPlugin("com.github.alexarchambault" % "coursier-sbt-plugin" % "1.0.0-M4")
addSbtPlugin("com.github.alexarchambault" % "coursier-sbt-plugin" % "1.0.0-M8")
addSbtPlugin("com.typesafe.sbt" % "sbt-proguard" % "0.2.2")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.8")