Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Scala 2.13-3.0 sandwich #5767

Merged
merged 1 commit into from
Aug 17, 2020
Merged

Conversation

eed3si9n
Copy link
Member

Fixes #5369
Ref https://contributors.scala-lang.org/t/roadmap-for-the-tasty-reader-for-scala-2/4231

This implements support for inter-project dependencies between Scala 2.13 and Dotty, and vice versa. Scala 2.13 depending on Dotty would require 2.13.4 and above.

ThisBuild / scalaVersion := "0.23.0"

ThisBuild / resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
// TODO use 2.13.4 when it's out
lazy val scala213 = "2.13.4-bin-aeee8f0"

lazy val root = (project in file("."))
  .aggregate(fooApp, fooCore, barApp, barCore)

lazy val fooApp = (project in file("foo-app"))
  .dependsOn(fooCore)

lazy val fooCore = (project in file("foo-core"))
  .settings(
    scalaVersion := scala213
  )

lazy val barApp = (project in file("bar-app"))
  .dependsOn(barCore)
  .settings(
    scalaVersion := scala213
  )

lazy val barCore = (project in file("bar-core"))

@eed3si9n
Copy link
Member Author

eed3si9n commented Aug 16, 2020

plugins/dotty-sandwich works on my machine :) but it's erring out on Travis CI:

[info] Running plugins/dotty-sandwich
[info] [info] welcome to sbt 1.4.0-SNAPSHOT (AdoptOpenJDK Java 11.0.1)
[info] [info] loading settings for project global-plugins from metals.sbt ...
[info] [info] loading global plugins from /tmp/sbt_d7daa57/global/plugins
[info] [info] loading settings for project sbt_d7daa57-build from plugins.sbt ...
[info] [info] loading project definition from /tmp/sbt_d7daa57/project
[info] [info] loading settings for project root from build.sbt ...
[info] [info] set current project to root (in build file:/tmp/sbt_d7daa57/)
[info] [info] compiling 1 Scala source to /tmp/sbt_d7daa57/foo-core/target/scala-2.13/classes ...
[info] [info] compiling 1 Scala source to /tmp/sbt_d7daa57/bar-core/target/scala-0.23/classes ...
[info] [info] Non-compiled module 'compiler-bridge_2.13' for Scala 2.13.4-bin-aeee8f0. Compiling...
[info] [info] done compiling
[info] [info] compiling 1 Scala source to /tmp/sbt_d7daa57/bar-app/target/scala-2.13/classes ...
[info] [info] Non-compiled module 'compiler-bridge_2.13' for Scala 2.13.4-bin-aeee8f0. Compiling...
[info] [info]   Compilation completed in 18.539s.
[info] [info]   Compilation completed in 24.223s.
[info] [info] Attempting to fetch org.scala-sbt:compiler-bridge_2.13:1.4.0-M10.
[info] [error] ## Exception when compiling 1 sources to /tmp/sbt_d7daa57/foo-core/target/scala-2.13/classes
[info] [error] sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$1$1: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: Cannot redefine component. ID: sbt.internal.scriptedtest.ScriptedLauncher$1@73f23e8e, files: /tmp/sbt_159a0475/org.scala-sbt-compiler-bridge_2.13-1.4.0-M10-bin_2.13.4-bin-aeee8f0__55.0.jar
[info] [error] 
[info] [error]            
[info] [info] done compiling
[info] [error] sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$1$1: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: Cannot redefine component. ID: sbt.internal.scriptedtest.ScriptedLauncher$1@73f23e8e, files: /tmp/sbt_159a0475/org.scala-sbt-compiler-bridge_2.13-1.4.0-M10-bin_2.13.4-bin-aeee8f0__55.0.jar
[info] [error] Caused by: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: Cannot redefine component. ID: sbt.internal.scriptedtest.ScriptedLauncher$1@73f23e8e, files: /tmp/sbt_159a0475/org.scala-sbt-compiler-bridge_2.13-1.4.0-M10-bin_2.13.4-bin-aeee8f0__55.0.jar
[info] [error] (fooCore / Compile / compileIncremental) sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$1$1: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: sbt.internal.scriptedtest.ScriptedLauncher$3$1$1$1$foo: Cannot redefine component. ID: sbt.internal.scriptedtest.ScriptedLauncher$1@73f23e8e, files: /tmp/sbt_159a0475/org.scala-sbt-compiler-bridge_2.13-1.4.0-M10-bin_2.13.4-bin-aeee8f0__55.0.jar
[error] x plugins/dotty-sandwich 
[error]  Cause of test exception: {line 1}  Command failed: compile failed

Looks like compiler bridge is being compiled twice?

Fixes sbt#5369
Ref https://contributors.scala-lang.org/t/roadmap-for-the-tasty-reader-for-scala-2/4231

This implements support for inter-project dependencies between Scala 2.13 and Dotty, and vice versa. Scala 2.13 depending on Dotty would require 2.13.4 and above.
.withConfigurations(dep.configuration)
.withExplicitArtifacts(Vector.empty)
)
else sys.error(s"scalaBinaryVersion mismatch: expected $sbv but found ${depSBV}")
Copy link
Contributor

@smarter smarter Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the error could mention the names of the mismatched projects?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project name should show up as projectDependencies task failure, I think.


lazy val fooCore = (project in file("foo-core"))
.settings(
scalaVersion := scala213
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness sake, I think it'd be nice to have one or more tests involving crossScalaVersion and running ++compile, e.g. what happens if I have a scala 3 app that depends on a lib that cross-compiles between 2 and 3, and vice-versa.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably not gonna work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I misreading previous @smarter comments? A 2.13.4+ (not released yet) should be able to depend on a dotty library, so why wouldn't this visa-versa test work?

Copy link
Member Author

@eed3si9n eed3si9n Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ command is ignorant about the sandwich, so if there is a list of scalaVersions it wouldn't know how to align them. I'd much rather handle that scenario using sbt-projectmatrix - sbt/sbt-projectmatrix#28

Copy link
Contributor

@er1c er1c Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for explaining! that makes sense!

@eed3si9n eed3si9n merged commit da9cf44 into sbt:develop Aug 17, 2020
@eed3si9n eed3si9n deleted the wip/dotty-mixed branch August 17, 2020 01:15
eed3si9n added a commit to sbt/sbt-projectmatrix that referenced this pull request Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants