mirror of https://github.com/sbt/sbt.git
Add --force option to the fetch CLI command, better error reporting
This commit is contained in:
parent
f12fcacc51
commit
dade161d3e
|
|
@ -95,11 +95,13 @@ case class Fetch(
|
||||||
@Help("Print java -cp compatible output")
|
@Help("Print java -cp compatible output")
|
||||||
@Short("p")
|
@Short("p")
|
||||||
classpath: Boolean,
|
classpath: Boolean,
|
||||||
|
@Help("Fetch artifacts even if the resolution is errored")
|
||||||
|
force: Boolean,
|
||||||
@Recurse
|
@Recurse
|
||||||
common: CommonOptions
|
common: CommonOptions
|
||||||
) extends CoursierCommand {
|
) extends CoursierCommand {
|
||||||
|
|
||||||
val helper = new Helper(common, remainingArgs)
|
val helper = new Helper(common, remainingArgs, ignoreErrors = force)
|
||||||
|
|
||||||
val files0 = helper.fetch(sources = sources, javadoc = javadoc)
|
val files0 = helper.fetch(sources = sources, javadoc = javadoc)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@ object Util {
|
||||||
class Helper(
|
class Helper(
|
||||||
common: CommonOptions,
|
common: CommonOptions,
|
||||||
rawDependencies: Seq[String],
|
rawDependencies: Seq[String],
|
||||||
printResultStdout: Boolean = false
|
printResultStdout: Boolean = false,
|
||||||
|
ignoreErrors: Boolean = false
|
||||||
) {
|
) {
|
||||||
import common._
|
import common._
|
||||||
import Helper.errPrintln
|
import Helper.errPrintln
|
||||||
|
|
@ -236,25 +237,6 @@ class Helper(
|
||||||
|
|
||||||
logger.foreach(_.stop())
|
logger.foreach(_.stop())
|
||||||
|
|
||||||
// FIXME Better to print all the messages related to the exit conditions below, then exit
|
|
||||||
// rather than exit at the first one
|
|
||||||
|
|
||||||
exitIf(!res.isDone) {
|
|
||||||
errPrintln(s"Maximum number of iteration reached!")
|
|
||||||
sys.exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
exitIf(res.errors.nonEmpty) {
|
|
||||||
s"\nError:\n" +
|
|
||||||
res.errors.map { case (dep, errs) =>
|
|
||||||
s" ${dep.module}:${dep.version}:\n${errs.map(" " + _.replace("\n", " \n")).mkString("\n")}"
|
|
||||||
}.mkString("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
exitIf(res.conflicts.nonEmpty) {
|
|
||||||
s"\nConflict:\n${Print.dependenciesUnknownConfigs(res.conflicts.toVector, projCache)}"
|
|
||||||
}
|
|
||||||
|
|
||||||
val trDeps = res.minDependencies.toVector
|
val trDeps = res.minDependencies.toVector
|
||||||
|
|
||||||
lazy val projCache = res.projectCache.mapValues { case (_, p) => p }
|
lazy val projCache = res.projectCache.mapValues { case (_, p) => p }
|
||||||
|
|
@ -268,6 +250,39 @@ class Helper(
|
||||||
errPrintln(depsStr)
|
errPrintln(depsStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var anyError = false
|
||||||
|
|
||||||
|
if (!res.isDone) {
|
||||||
|
anyError = true
|
||||||
|
errPrintln("\nMaximum number of iterations reached!")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.errors.nonEmpty) {
|
||||||
|
anyError = true
|
||||||
|
errPrintln(
|
||||||
|
s"\nError:\n" +
|
||||||
|
res.errors.map {
|
||||||
|
case (dep, errs) =>
|
||||||
|
s" ${dep.module}:${dep.version}:\n${errs.map(" " + _.replace("\n", " \n")).mkString("\n")}"
|
||||||
|
}.mkString("\n")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.conflicts.nonEmpty) {
|
||||||
|
anyError = true
|
||||||
|
errPrintln(
|
||||||
|
s"\nConflict:\n" +
|
||||||
|
Print.dependenciesUnknownConfigs(res.conflicts.toVector, projCache)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anyError) {
|
||||||
|
if (ignoreErrors)
|
||||||
|
errPrintln("Ignoring errors")
|
||||||
|
else
|
||||||
|
sys.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
def fetch(
|
def fetch(
|
||||||
sources: Boolean,
|
sources: Boolean,
|
||||||
javadoc: Boolean,
|
javadoc: Boolean,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue