-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Upgrade to sbt 1 #3441
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
Upgrade to sbt 1 #3441
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
Awesome! :) |
@ttreyer Could you please sign the Scala CLA at https://www.lightbend.com/contribute/cla/scala ? That way we'll finally be able to merge your code 😄 |
project/Build.scala
Outdated
@@ -150,8 +151,8 @@ object Build { | |||
|
|||
// Avoid having to run `dotty-sbt-bridge/publishLocal` before compiling a bootstrapped project | |||
scalaCompilerBridgeSource := | |||
(dottyOrganization %% "dotty-sbt-bridge" % dottyVersion % Configurations.Component.name) | |||
.artifacts(Artifact.sources("dotty-sbt-bridge").copy(url = | |||
(dottyOrganization %% "dotty-sbt-bridge" % "NOT_PUBLISHED" % Configurations.Component.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A change was accidentally reverted here: we stopped using NOT_PUBLISHED in 78ac17a
Until we're ready to merge this PR, we should enable running all the sbt scripted tests on every push to make sure everything passes. |
sbt/zinc#444 should be ported here too. |
moduleID | ||
} | ||
} | ||
implicit class DottyCompatModuleID(moduleID: ModuleID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space in indentation
} | ||
|
||
import autoImport._ | ||
|
||
override def requires: Plugins = plugins.JvmPlugin | ||
override def trigger = allRequirements | ||
|
||
// Adapted from CrossVersionUtil#sbtApiVersion | ||
// Adapted from CrossVersioconstant nUtil#sbtApiVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typos
project/Build.scala
Outdated
).map(_.withDottyCompat()) | ||
dottyOrganization % "dotty-library_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name, | ||
dottyOrganization % "dotty-compiler_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name | ||
)//.map(_.withDottyCompat(scalaVersion.value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be reverted now that withDottyCompat
has been ported.
I addressed the comments so far. I've ported sbt/zinc#444 here. All the scripted tests are already being run on every push for this PR. I've also finished upgrading all the projects of the community build to sbt 1.0.3 and proposed to upstream the changes. To test the community build:
|
project/Build.scala
Outdated
// By default scripted tests use $HOME/.ivy2 for the ivy cache. We need to override this value for the CI. | ||
ScriptedPlugin.scriptedLaunchOpts ++= ivyPaths.value.ivyHome.map("-Dsbt.ivy.home=" + _.getAbsolutePath).toList, | ||
ScriptedPlugin.scripted := ScriptedPlugin.scripted.dependsOn(Def.task { | ||
version := "0.1.6-SNAPSHOT", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.8
project/Build.scala
Outdated
@@ -199,7 +199,7 @@ object Build { | |||
Seq( | |||
dottyOrganization % "dotty-library_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name, | |||
dottyOrganization % "dotty-compiler_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line and the line above also need to be reverted to not use "_2.11"
underlying :: ancestorTypes0 | ||
} else | ||
ancestorTypes0 | ||
} catch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try/catch should only be needed around the call to linearizedAncestorTypes(cinfo)
.
First draft at fixing the sbt bridge to match the Zinc 1.0 API.
After sbt/zinc#101, SimpleType simply doesn't exist anymore.
Some of sbt's callbacks need the full name of the class that can only be accessed during the first step of the GenBCode pipeline. So we call the callbacks in the first step, generating at the same time the class files, and keep those files through the whole pipeline so the last step can write the bytecode in them.
A FileConflictException may occure when creating a class file. Add check for this error and refactor a bit of code around it.
project/Build.scala
Outdated
@@ -862,7 +862,7 @@ object Build { | |||
unmanagedSourceDirectories in Compile += | |||
baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config", | |||
sbtPlugin := true, | |||
version := "0.1.6-SNAPSHOT", | |||
version := "0.1.8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an incompatible change, I would bump to 0.2.0
def apply(x: Option[Symbol], t: Tree)(implicit ctx: Context) = | ||
if (x.isDefined) x | ||
else t match { | ||
case moduleDef: Thicket => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this case is ever going to be hit, objects in Dotty after Typer are represented by a TypeDef and a ValDef, the TypeDef case below will be used.
else { | ||
val file = Option(sym.associatedFile) | ||
|
||
Option(sym.associatedFile).flatMap { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this is for, if the symbol comes from source then sym.associatedFile
will never be NoSourceFile
.
} | ||
} else if (depFile.file != currentSourceFile) { | ||
ctx.sbtCallback.classDependency(extractedName(dep.enclosingClass), extractedName(currentClass), context) | ||
val onSource = dep.sourceFile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed? This is also very likely to do the wrong thing. If dep
was loaded from TASTY, dep.sourceFile
will return the source filename stored in the SoureFile attribute of the TASTY section. But here we're really interested in recording the dependency on the classfile where dep
comes from, because if this classfile changes we'll have to recompile the current unit.
builder.append(" in [") | ||
otherScopes.forEach(new java.util.function.Consumer[UseScope]() { | ||
def accept(scope: UseScope): Unit = | ||
// Pickling tests fail when this is turned in an anonymous class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you open an issue so we don't forget about this?
@@ -182,13 +246,13 @@ private final class NameUsedInClass { | |||
* specially, see the subsection "Dependencies introduced by member reference and | |||
* inheritance" in the "Name hashing algorithm" section. | |||
*/ | |||
private class ExtractDependenciesCollector(implicit val ctx: Context) extends tpd.TreeTraverser { thisTreeTraverser => | |||
private class ExtractDependenciesCollector(responsibleForImports: Symbol)(implicit val ctx: Context) extends tpd.TreeTraverser { thisTreeTraverser => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some documentation for this parameter
@@ -199,15 +263,18 @@ private class ExtractDependenciesCollector(implicit val ctx: Context) extends tp | |||
* because it refers to these classes or something defined in them. | |||
* This is always a superset of `topLevelInheritanceDependencies` by definition. | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation needs to be updated since this is now a set of pair, same for the def just below.
|
||
private def addUsedName(enclosingSym: Symbol, name: Name) = { | ||
val enclosingName = extractedName(enclosingSym) | ||
val enclosingName = enclosingSym match { | ||
case sym if sym == defn.RootClass => ExtractDependencies.extractedName(responsibleForImports) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a pattern match and not just an if/else here?
@@ -276,19 +349,20 @@ private class ExtractDependenciesCollector(implicit val ctx: Context) extends tp | |||
addImported(name) | |||
case Thicket(Ident(name) :: Ident(rename) :: Nil) => | |||
addImported(name) | |||
if (rename ne nme.WILDCARD) | |||
if (rename ne nme.WILDCARD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary brackets
|
||
private object PatMatDependencyTraverser extends ExtractTypesCollector { | ||
private class PatMatDependencyTraverser(ctx0: Context) extends ExtractTypesCollector(ctx0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not implicit ctx: Context
? And at the same time, the implicit ctx: Context
argument to method in this class should be removed.
SafeLazyWrapper.strict(t) | ||
} | ||
|
||
/** Wrapper around SafeLazy implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So great that we can get rid of this stuff 😄 🔥
name, acc, modifiers, anns, defType, api.SafeLazy.strict(selfType), api.SafeLazy.strict(structure), Constants.emptyStringArray, | ||
childrenOfSealedClass, topLevel, tparams) | ||
|
||
// if (name.toString.contains("DottyPredef")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug code
|
||
allNonLocalClassesInSrc += cl | ||
|
||
val javaPlatform = ctx.platform.asInstanceOf[JavaPlatform] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid the cast here, we don't want the compiler to crash when run with the Scala.js backend. I think we should just move hasJavaMainMethod
outside of JavaPlatform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, especially since Scala.js supports exactly the same main methods as Scala/JVM!
// } | ||
} | ||
|
||
private final class NameUsedInClass { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the added classes/objects in this PR should get a documentation comment.
Is there any chance this can be merged and released together with 0.5.0-RC1? I'd like to try cross-compiling bloop to Dotty. For now, I'm doing it locally, but ideally I'd have an official version to depend on so that the CI passes my changes. |
No, that would require delaying the release too much. But once this PR is merged you'll be able to use our nightly builds in your project, using a nightly build of Dotty is just as easy as using a release. |
We had a regression with |
else | ||
(incOptions in Compile).value | ||
scalaBridge | ||
}, | ||
|
||
scalaBinaryVersion := { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be remove?
image: lampepfl/dotty:2017-10-20 | ||
commands: | ||
- cp -R . /tmp/5/ && cd /tmp/5/ | ||
- ./project/scripts/sbt "sbt-dotty/scripted source-dependencies/*2of2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complain to the sbt people: sbt/sbt#3469 Maybe ask someone who has a lightbend subscription? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could try copy-pasting the custom implementation of scripted used by zinc, it even has parallelism and fancy colors contributed by @jvican :P. https://github.com/sbt/zinc/blob/1.x/project/Scripted.scala https://github.com/sbt/zinc/tree/1.x/internal/zinc-scripted/src/test/scala/sbt/internal/inc
Good catch @allanrenucci : |
Unfortunately |
@allanrenucci @liufengyun Released sbt-pack 0.10.0, which fixes an issue of including too many modules. xerial/sbt-pack#67 |
Released sbt-pack 0.10.1, which fixes a bug if you have multiple nested projects in build.sbt. Please use this version. Thanks. |
Thanks @xerial! I can confirm this fixes our issue |
I'm closing this PR given that it's been rebased in #3687. @allanrenucci next time just merge master into the existing PR, rebasing doesn't scale to multiple committers and long standing PRs... |
This partially reverts 06a3d47 to bring back Dotty.js from the dead. Many things are broken still, but this is enough to do some experiments: - The backend was initially removed because of scala#1574, I don't see why GetClass has a requirement on FunctionalInterfaces, so I just removed it ¯\_(ツ)_/¯ - Scala.js was upgraded to 0.6.19. More recent versions of Scala.js cannot be used because they require sbt 0.13.16 and we're blocked by sbt/sbt#3460, this won't be an issue anymore once we switch to sbt 1 (see scala#3441) - GenSJSIR was hacked to compile with 0.6.19 but is missing most of the changes to the Scala.js backend phase for Scala 2 that happened since it was initially ported to Dotty from Scala.js 0.6.8 - scalajs-ir does not compile with Dotty anymore, see comments in Build.scala - The Scala.js backend explodes when extending a Scala 2 trait because of the way LinkScala2Impls transforms supercalls to these traits. Luckily, we don't need to extend js.JSApp anymore to make a Hello World :P. I verified that the following works: sbt sjsSandbox/run But I don't know if anything else does!
This partially reverts 06a3d47 to bring back Dotty.js from the dead. Many things are broken still, but this is enough to do some experiments: - The backend was initially removed because of scala#1574, I don't see why GetClass has a requirement on FunctionalInterfaces, so I just removed it ¯\_(ツ)_/¯ - Scala.js was upgraded to 0.6.19. More recent versions of Scala.js cannot be used because they require sbt 0.13.16 and we're blocked by sbt/sbt#3460, this won't be an issue anymore once we switch to sbt 1 (see scala#3441) - GenSJSIR was hacked to compile with 0.6.19 but is missing most of the changes to the Scala.js backend phase for Scala 2 that happened since it was initially ported to Dotty from Scala.js 0.6.8 - scalajs-ir does not compile with Dotty anymore, see comments in Build.scala - The Scala.js backend explodes when extending a Scala 2 trait because of the way LinkScala2Impls transforms supercalls to these traits. Luckily, we don't need to extend js.JSApp anymore to make a Hello World :P. I verified that the following works: sbt sjsSandbox/run But I don't know if anything else does!
Projects from the community build to port to sbt1: