Merge pull request #5984 from xuwei-k/dotty-sandwich-scala-js

Scala-2-dependsOn-Scala-3 feature with Scala.js
This commit is contained in:
eugene yokota 2020-10-18 04:05:43 -04:00 committed by GitHub
commit a9f62f8453
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 8 deletions

View File

@ -3590,17 +3590,18 @@ object Classpaths {
deps.classpath(ref) flatMap { dep =>
for {
depProjId <- (dep.project / projectID).get(data)
depSV <- (dep.project / scalaVersion).get(data)
depSBV <- (dep.project / scalaBinaryVersion).get(data)
depCross <- (dep.project / crossVersion).get(data)
} yield {
if (isScala2Scala3Sandwich(sbv, depSBV) && depCross == CrossVersion.binary)
depProjId
.withCrossVersion(CrossVersion.constant(depSBV))
.withConfigurations(dep.configuration)
.withExplicitArtifacts(Vector.empty)
else
depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty)
depCross match {
case b: CrossVersion.Binary if isScala2Scala3Sandwich(sbv, depSBV) =>
depProjId
.withCrossVersion(CrossVersion.constant(b.prefix + depSBV))
.withConfigurations(dep.configuration)
.withExplicitArtifacts(Vector.empty)
case _ =>
depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty)
}
}
}
}

View File

@ -0,0 +1,9 @@
package app
import mylib._
object Main {
def main(args: Array[String]): Unit = {
println(MyLib.square(5))
}
}

View File

@ -0,0 +1,17 @@
// TODO use 2.13.4 when it's out
ThisBuild / scalaVersion := "2.13.4-bin-d526da6"
Global / resolvers += "scala-integration".at("https://scala-ci.typesafe.com/artifactory/scala-integration/")
lazy val scala3code = project
.enablePlugins(ScalaJSPlugin)
.settings(scalaVersion := "0.27.0-RC1")
lazy val app = project
.enablePlugins(ScalaJSPlugin)
.dependsOn(scala3code)
.settings(
libraryDependencies ~= (_.filterNot(_.name.contains("scalajs-compiler"))),
addCompilerPlugin("org.scala-js" % "scalajs-compiler_2.13.3" % scalaJSVersion),
scalaJSUseMainModuleInitializer := true,
)

View File

@ -0,0 +1,2 @@
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0")

View File

@ -0,0 +1,5 @@
package mylib
object MyLib {
def square(x: Int): Int = x * x
}

View File

@ -0,0 +1 @@
> app/run