Skip to content

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

Closed
wants to merge 49 commits into from
Closed

Upgrade to sbt 1 #3441

wants to merge 49 commits into from

Conversation

Duhemm
Copy link
Contributor

@Duhemm Duhemm commented Nov 7, 2017

Projects from the community build to port to sbt1:

Copy link
Member

@dottybot dottybot left a 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! ☀️

@smarter
Copy link
Member

smarter commented Nov 7, 2017

Awesome! :)

@smarter
Copy link
Member

smarter commented Nov 7, 2017

@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 😄

@@ -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)
Copy link
Member

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

@smarter
Copy link
Member

smarter commented Nov 7, 2017

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.

@smarter
Copy link
Member

smarter commented Nov 7, 2017

sbt/zinc#444 should be ported here too.

moduleID
}
}
implicit class DottyCompatModuleID(moduleID: ModuleID) {
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

typos

).map(_.withDottyCompat())
dottyOrganization % "dotty-library_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name,
dottyOrganization % "dotty-compiler_2.11" % dottyNonBootstrappedVersion % Configurations.ScalaTool.name
)//.map(_.withDottyCompat(scalaVersion.value))
Copy link
Member

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.

@Duhemm
Copy link
Contributor Author

Duhemm commented Nov 8, 2017

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:

  • checkout the branch sbt1 in dotty-community-build
  • DOTTY_REFERENCE="+refs/pull/3441/merge" ./run.sh

// 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",
Copy link
Contributor

Choose a reason for hiding this comment

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

1.8

@@ -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
Copy link
Member

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 {
Copy link
Member

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).

smarter and others added 17 commits November 13, 2017 07:49
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.
@@ -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",
Copy link
Member

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 =>
Copy link
Member

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 {
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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 =>
Copy link
Member

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.
*/
Copy link
Member

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)
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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.
Copy link
Member

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")) {
Copy link
Member

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]
Copy link
Member

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

Copy link
Member

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 {
Copy link
Member

@smarter smarter Nov 22, 2017

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.

@jvican
Copy link
Member

jvican commented Nov 28, 2017

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.

@smarter
Copy link
Member

smarter commented Nov 28, 2017

Is there any chance this can be merged and released together with 0.5.0-RC1?

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.

@allanrenucci
Copy link
Contributor

We had a regression with sbt-pack #3124: the generated jar contained the non-bootstrapped version. Since you are updating the version, it would be good to know if the issue is still present.
/cc @liufengyun

else
(incOptions in Compile).value
scalaBridge
},

scalaBinaryVersion := {
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great if we did not introduce this huge regression (3x) in the time needed to run the scripted tests.
@Duhemm says it is because the bridge is recompiled for each scripted test. @smarter do you have an idea how this could be fixed?

Copy link
Member

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? :)

Copy link
Member

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

@liufengyun
Copy link
Contributor

Good catch @allanrenucci : 0.9.1 is the version where we had the regression. The latest version for sbt-pack is 1.0.4. We can run dist-bootstrapped/pack, if the generated jars are good, then there's no worry.

@allanrenucci
Copy link
Contributor

Unfortunately dist-bootstrapped/pack generates the non bootstrapped jars

@allanrenucci allanrenucci mentioned this pull request Dec 21, 2017
@xerial
Copy link
Contributor

xerial commented Jan 11, 2018

@allanrenucci @liufengyun Released sbt-pack 0.10.0, which fixes an issue of including too many modules. xerial/sbt-pack#67

@xerial
Copy link
Contributor

xerial commented Jan 13, 2018

Released sbt-pack 0.10.1, which fixes a bug if you have multiple nested projects in build.sbt. Please use this version. Thanks.

@allanrenucci
Copy link
Contributor

Thanks @xerial! I can confirm this fixes our issue

@OlivierBlanvillain
Copy link
Contributor

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...

@allanrenucci allanrenucci mentioned this pull request Jan 19, 2018
sjrd pushed a commit to sjrd/dotty that referenced this pull request Sep 22, 2018
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!
sjrd pushed a commit to dotty-staging/dotty that referenced this pull request Nov 8, 2018
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!
@Duhemm Duhemm deleted the topic/sbt1 branch November 30, 2018 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants