mirror of https://github.com/sbt/sbt.git
Explicit list of artifacts for Scala binary version check. Fixes #2701
This commit is contained in:
parent
bf7918f072
commit
2d31681220
|
|
@ -20,6 +20,7 @@ object ScalaArtifacts {
|
||||||
val ReflectID = "scala-reflect"
|
val ReflectID = "scala-reflect"
|
||||||
val ActorsID = "scala-actors"
|
val ActorsID = "scala-actors"
|
||||||
val ScalapID = "scalap"
|
val ScalapID = "scalap"
|
||||||
|
val Artifacts = Seq(LibraryID, CompilerID, ReflectID, ActorsID, ScalapID)
|
||||||
val DottyIDPrefix = "dotty"
|
val DottyIDPrefix = "dotty"
|
||||||
|
|
||||||
def dottyID(binaryVersion: String): String = s"${DottyIDPrefix}_${binaryVersion}"
|
def dottyID(binaryVersion: String): String = s"${DottyIDPrefix}_${binaryVersion}"
|
||||||
|
|
@ -102,11 +103,10 @@ private object IvyScala {
|
||||||
val id = dep.getDependencyRevisionId
|
val id = dep.getDependencyRevisionId
|
||||||
val depBinaryVersion = CrossVersion.binaryScalaVersion(id.getRevision)
|
val depBinaryVersion = CrossVersion.binaryScalaVersion(id.getRevision)
|
||||||
def isScalaLangOrg = id.getOrganisation == scalaOrganization
|
def isScalaLangOrg = id.getOrganisation == scalaOrganization
|
||||||
def isNotScalaActorsMigration = !(id.getName startsWith "scala-actors-migration") // Exception to the rule: sbt/sbt#1818
|
def isScalaArtifact = Artifacts.contains(id.getName)
|
||||||
def isNotScalaPickling = !(id.getName startsWith "scala-pickling") // Exception to the rule: sbt/sbt#1899
|
|
||||||
def hasBinVerMismatch = depBinaryVersion != scalaBinaryVersion
|
def hasBinVerMismatch = depBinaryVersion != scalaBinaryVersion
|
||||||
def matchesOneOfTheConfigs = dep.getModuleConfigurations.exists(configSet)
|
def matchesOneOfTheConfigs = dep.getModuleConfigurations.exists(configSet)
|
||||||
val mismatched = isScalaLangOrg && isNotScalaActorsMigration && isNotScalaPickling && hasBinVerMismatch && matchesOneOfTheConfigs
|
val mismatched = isScalaLangOrg && isScalaArtifact && hasBinVerMismatch && matchesOneOfTheConfigs
|
||||||
if (mismatched)
|
if (mismatched)
|
||||||
Some("Binary version (" + depBinaryVersion + ") for dependency " + id +
|
Some("Binary version (" + depBinaryVersion + ") for dependency " + id +
|
||||||
"\n\tin " + module.getModuleRevisionId +
|
"\n\tin " + module.getModuleRevisionId +
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
scalaOrganization := "org.other"
|
||||||
|
|
||||||
|
scalaVersion := "2.11.8"
|
||||||
|
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"org.other" %% "thing" % "1.2.3"
|
||||||
|
)
|
||||||
|
|
||||||
|
lazy val check = taskKey[Unit]("Runs the check")
|
||||||
|
|
||||||
|
check := {
|
||||||
|
val lastLog = BuiltinCommands lastLogFile state.value
|
||||||
|
val last = IO read lastLog.get
|
||||||
|
def containsWarn1 = last contains "Binary version (1.2.3) for dependency org.other#thing_2.11;1.2.3"
|
||||||
|
def containsWarn2 = last contains "differs from Scala binary version in project (2.11)."
|
||||||
|
if (containsWarn1) sys error "thing should be exempted from the Scala binary version check"
|
||||||
|
if (containsWarn2) sys error "Binary version check failed"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
> clean
|
||||||
|
|
||||||
|
> check
|
||||||
Loading…
Reference in New Issue