mirror of https://github.com/sbt/sbt.git
Add ignore errors flag
This commit is contained in:
parent
5ceed97587
commit
a03f0ad437
|
|
@ -302,6 +302,7 @@ addCommandAlias("scriptedIvy", Seq(
|
|||
|
||||
addCommandAlias("scriptedCoursier", Seq(
|
||||
"lmCore/publishLocal",
|
||||
"lmIvy/publishLocal",
|
||||
"lmCoursier/publishLocal",
|
||||
"lmScriptedTest/clean",
|
||||
"""set ThisBuild / scriptedTestLMImpl := "coursier"""",
|
||||
|
|
|
|||
|
|
@ -10,22 +10,23 @@ final class CoursierConfiguration private (
|
|||
val otherResolvers: Vector[sbt.librarymanagement.Resolver],
|
||||
val reorderResolvers: Boolean,
|
||||
val parallelDownloads: Int,
|
||||
val maxIterations: Int) extends Serializable {
|
||||
val maxIterations: Int,
|
||||
val ignoreArtifactErrors: Boolean) extends Serializable {
|
||||
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, Vector.empty, true, 6, 100)
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, Vector.empty, true, 6, 100, false)
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.otherResolvers == x.otherResolvers) && (this.reorderResolvers == x.reorderResolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations)
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.otherResolvers == x.otherResolvers) && (this.reorderResolvers == x.reorderResolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.ignoreArtifactErrors == x.ignoreArtifactErrors)
|
||||
case _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.coursier.CoursierConfiguration".##) + log.##) + resolvers.##) + otherResolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##)
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.coursier.CoursierConfiguration".##) + log.##) + resolvers.##) + otherResolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + ignoreArtifactErrors.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + otherResolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ")"
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + otherResolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + ignoreArtifactErrors + ")"
|
||||
}
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, otherResolvers: Vector[sbt.librarymanagement.Resolver] = otherResolvers, reorderResolvers: Boolean = reorderResolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations)
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, otherResolvers: Vector[sbt.librarymanagement.Resolver] = otherResolvers, reorderResolvers: Boolean = reorderResolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, ignoreArtifactErrors: Boolean = ignoreArtifactErrors): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, ignoreArtifactErrors)
|
||||
}
|
||||
def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = {
|
||||
copy(log = log)
|
||||
|
|
@ -48,10 +49,13 @@ final class CoursierConfiguration private (
|
|||
def withMaxIterations(maxIterations: Int): CoursierConfiguration = {
|
||||
copy(maxIterations = maxIterations)
|
||||
}
|
||||
def withIgnoreArtifactErrors(ignoreArtifactErrors: Boolean): CoursierConfiguration = {
|
||||
copy(ignoreArtifactErrors = ignoreArtifactErrors)
|
||||
}
|
||||
}
|
||||
object CoursierConfiguration {
|
||||
|
||||
def apply(): CoursierConfiguration = new CoursierConfiguration()
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int): CoursierConfiguration = new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations)
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, ignoreArtifactErrors: Boolean): CoursierConfiguration = new CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, ignoreArtifactErrors)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], otherResolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, ignoreArtifactErrors: Boolean): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, ignoreArtifactErrors)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ implicit lazy val CoursierConfigurationFormat: JsonFormat[sbt.librarymanagement.
|
|||
val reorderResolvers = unbuilder.readField[Boolean]("reorderResolvers")
|
||||
val parallelDownloads = unbuilder.readField[Int]("parallelDownloads")
|
||||
val maxIterations = unbuilder.readField[Int]("maxIterations")
|
||||
val ignoreArtifactErrors = unbuilder.readField[Boolean]("ignoreArtifactErrors")
|
||||
unbuilder.endObject()
|
||||
sbt.librarymanagement.coursier.CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations)
|
||||
sbt.librarymanagement.coursier.CoursierConfiguration(log, resolvers, otherResolvers, reorderResolvers, parallelDownloads, maxIterations, ignoreArtifactErrors)
|
||||
case None =>
|
||||
deserializationError("Expected JsObject but found None")
|
||||
}
|
||||
|
|
@ -31,6 +32,7 @@ implicit lazy val CoursierConfigurationFormat: JsonFormat[sbt.librarymanagement.
|
|||
builder.addField("reorderResolvers", obj.reorderResolvers)
|
||||
builder.addField("parallelDownloads", obj.parallelDownloads)
|
||||
builder.addField("maxIterations", obj.maxIterations)
|
||||
builder.addField("ignoreArtifactErrors", obj.ignoreArtifactErrors)
|
||||
builder.endObject()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@
|
|||
"type": "Int",
|
||||
"default": "100",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "ignoreArtifactErrors",
|
||||
"type": "Boolean",
|
||||
"default": "false",
|
||||
"since": "0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,10 +143,12 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
|||
val start = Resolution(dependencies)
|
||||
val authentication = None // TODO: get correct value
|
||||
val ivyConfiguration = ivyProperties // TODO: is it enough?
|
||||
|
||||
val repositories =
|
||||
reorderedResolvers.flatMap(r => FromSbt.repository(r, ivyConfiguration, log, authentication)) ++ Seq(
|
||||
Cache.ivy2Local,
|
||||
Cache.ivy2Cache)
|
||||
Cache.ivy2Cache
|
||||
)
|
||||
|
||||
implicit val ec = pool
|
||||
|
||||
|
|
@ -160,17 +162,34 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
|||
.run(fetch, coursierConfiguration.maxIterations)
|
||||
.unsafeRun()
|
||||
|
||||
if (resolution.isDone && resolution.errors.isEmpty && resolution.conflicts.isEmpty) {
|
||||
def updateReport() = {
|
||||
val localArtifacts: Map[Artifact, Either[FileError, File]] = Gather[Task]
|
||||
.gather(
|
||||
resolution.artifacts.map { a =>
|
||||
Cache.file[Task](a, logger = Some(coursierLogger)).run.map((a, _))
|
||||
Cache
|
||||
.file[Task](a, logger = Some(coursierLogger))
|
||||
.run
|
||||
.map((a, _))
|
||||
}
|
||||
)
|
||||
.unsafeRun()
|
||||
.toMap
|
||||
|
||||
toUpdateReport(resolution, localArtifacts, log)
|
||||
}
|
||||
|
||||
if (resolution.isDone &&
|
||||
resolution.errors.isEmpty &&
|
||||
resolution.conflicts.isEmpty) {
|
||||
updateReport()
|
||||
} else if (resolution.isDone &&
|
||||
(!resolution.errors.isEmpty && coursierConfiguration.ignoreArtifactErrors)
|
||||
&& resolution.conflicts.isEmpty) {
|
||||
log.warn(s"""Failed to download artifacts: ${resolution.errors
|
||||
.map(_._2)
|
||||
.flatten
|
||||
.mkString(", ")}""")
|
||||
updateReport()
|
||||
} else {
|
||||
toSbtError(log, uwconfig, resolution)
|
||||
}
|
||||
|
|
@ -232,17 +251,12 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
|||
a -> err
|
||||
}
|
||||
|
||||
if (artifactErrors.nonEmpty) {
|
||||
// TODO: handle error the correct sbt way
|
||||
throw new RuntimeException(s"Could not download dependencies: $artifactErrors")
|
||||
}
|
||||
|
||||
// can be non empty only if ignoreArtifactErrors is true or some optional artifacts are not found
|
||||
val erroredArtifacts = artifactFilesOrErrors0.collect {
|
||||
case (a, Left(_)) => a
|
||||
}.toSet
|
||||
|
||||
val depsByConfig = resolution.dependencies.groupBy(_.configuration).mapValues(_.toSeq)
|
||||
val depsByConfig =
|
||||
resolution.dependencies.groupBy(_.configuration).mapValues(_.toSeq)
|
||||
|
||||
val configurations = extractConfigurationTree
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue