Dummy refactoring / comment

This commit is contained in:
Alexandre Archambault 2018-11-22 10:19:32 +01:00
parent da58ebdaf8
commit d898c79b54
4 changed files with 43 additions and 54 deletions

View File

@ -254,7 +254,7 @@ object ToSbt {
}
UpdateReport(
new File("."),
new File("."), // dummy value
configReports.toVector,
UpdateStats(-1L, -1L, -1L, cached = false),
Map.empty

View File

@ -15,4 +15,44 @@ final case class UpdateParams(
ignoreArtifactErrors: Boolean,
includeSignatures: Boolean,
sbtBootJarOverrides: Map[(Module, String), File]
)
) {
lazy val artifactFiles = artifacts.collect {
case (artifact, Right(file)) =>
artifact -> file
}
// can be non empty only if ignoreArtifactErrors is true or some optional artifacts are not found
lazy val erroredArtifacts = artifacts
.collect {
case (artifact, Left(_)) =>
artifact
}
.toSet
def artifactFileOpt(
module: Module,
version: String,
attributes: Attributes,
artifact: Artifact
): Option[File] = {
// Under some conditions, SBT puts the scala JARs of its own classpath
// in the application classpath. Ensuring we return SBT's jars rather than
// JARs from the coursier cache, so that a same JAR doesn't land twice in the
// application classpath (once via SBT jars, once via coursier cache).
val fromBootJars =
if (attributes.classifier.isEmpty && attributes.`type` == Type.jar)
sbtBootJarOverrides.get((module, version))
else
None
val res = fromBootJars.orElse(artifactFiles.get(artifact))
if (res.isEmpty && !erroredArtifacts(artifact))
sys.error(s"${artifact.url} not downloaded (should not happen)")
res
}
}

View File

@ -1,7 +1,5 @@
package coursier.lmcoursier
import java.io.File
import coursier.core.Resolution.ModuleVersion
import coursier.core._
import coursier.util.Print
@ -10,35 +8,6 @@ import sbt.util.Logger
object UpdateRun {
private def artifactFileOpt(
sbtBootJarOverrides: Map[(Module, String), File],
artifactFiles: Map[Artifact, File],
erroredArtifacts: Set[Artifact]
)(
module: Module,
version: String,
attributes: Attributes,
artifact: Artifact
): Option[File] = {
// Under some conditions, SBT puts the scala JARs of its own classpath
// in the application classpath. Ensuring we return SBT's jars rather than
// JARs from the coursier cache, so that a same JAR doesn't land twice in the
// application classpath (once via SBT jars, once via coursier cache).
val fromBootJars =
if (attributes.classifier.isEmpty && attributes.`type` == Type.jar)
sbtBootJarOverrides.get((module, version))
else
None
val res = fromBootJars.orElse(artifactFiles.get(artifact))
if (res.isEmpty && !erroredArtifacts(artifact))
sys.error(s"${artifact.url} not downloaded (should not happen)")
res
}
// Move back to coursier.util (in core module) after 1.0?
private def allDependenciesByConfig(
res: Map[Configuration, Resolution],
@ -114,11 +83,6 @@ object UpdateRun {
log.info(repr.split('\n').map(" " + _).mkString("\n"))
}
val artifactFiles = params.artifacts.collect {
case (artifact, Right(file)) =>
artifact -> file
}
val artifactErrors = params
.artifacts
.toVector
@ -127,26 +91,13 @@ object UpdateRun {
a -> err
}
// can be non empty only if ignoreArtifactErrors is true or some optional artifacts are not found
val erroredArtifacts = params
.artifacts
.collect {
case (artifact, Left(_)) =>
artifact
}
.toSet
def report =
ToSbt.updateReport(
depsByConfig,
configResolutions,
params.configs,
params.classifiers,
artifactFileOpt(
params.sbtBootJarOverrides,
artifactFiles,
erroredArtifacts
),
params.artifactFileOpt,
log,
includeSignatures = params.includeSignatures
)

View File

@ -1,7 +1,5 @@
package coursier.sbtcoursiershared
import java.net.URL
import coursier.core._
import coursier.lmcoursier._
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._