Skip to content

Commit d6155fb

Browse files
committed
Upgrade to sbt 1.3.6, release sbt-dotty 0.4.0
Switching to sbt 1.3 allows us to pass both the scala-library and dotty-library jars as standard library jars to `ScalaInstance` whereas before we could only pass one of them which could have weird consequences.
1 parent 377f0a5 commit d6155fb

File tree

6 files changed

+48
-58
lines changed

6 files changed

+48
-58
lines changed

.drone.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ steps:
2727

2828
- name: test
2929
pull: default
30-
image: lampepfl/dotty:2019-10-17
30+
image: lampepfl/dotty:2020-01-09
3131
depends_on: [ clone ]
3232
commands:
3333
- cp -R . /tmp/1/ && cd /tmp/1/
@@ -36,7 +36,7 @@ steps:
3636

3737
- name: test_bootstrapped
3838
pull: default
39-
image: lampepfl/dotty:2019-10-17
39+
image: lampepfl/dotty:2020-01-09
4040
depends_on: [ clone ]
4141
commands:
4242
- cp -R . /tmp/2/ && cd /tmp/2/
@@ -45,7 +45,7 @@ steps:
4545

4646
- name: community_build
4747
pull: default
48-
image: lampepfl/dotty:2019-10-17
48+
image: lampepfl/dotty:2020-01-09
4949
depends_on: [ clone ]
5050
commands:
5151
- cp -R . /tmp/3/ && cd /tmp/3/
@@ -55,7 +55,7 @@ steps:
5555

5656
- name: test_sbt
5757
pull: default
58-
image: lampepfl/dotty:2019-10-17
58+
image: lampepfl/dotty:2020-01-09
5959
depends_on: [ clone ]
6060
commands:
6161
- cp -R . /tmp/4/ && cd /tmp/4/
@@ -67,7 +67,7 @@ steps:
6767

6868
- name: test_java11
6969
pull: default
70-
image: lampepfl/dotty:2019-10-17
70+
image: lampepfl/dotty:2020-01-09
7171
depends_on: [ clone ]
7272
commands:
7373
- export PATH="/usr/lib/jvm/java-11-openjdk-amd64/bin:$PATH"
@@ -80,7 +80,7 @@ steps:
8080

8181
- name: documentation
8282
pull: default
83-
image: lampepfl/dotty:2019-10-17
83+
image: lampepfl/dotty:2020-01-09
8484
depends_on:
8585
- test
8686
- test_bootstrapped
@@ -99,7 +99,7 @@ steps:
9999

100100
- name: publish_nightly
101101
pull: default
102-
image: lampepfl/dotty:2019-10-17
102+
image: lampepfl/dotty:2020-01-09
103103
depends_on:
104104
- test
105105
- test_bootstrapped
@@ -126,7 +126,7 @@ steps:
126126

127127
- name: publish_release
128128
pull: default
129-
image: lampepfl/dotty:2019-10-17
129+
image: lampepfl/dotty:2020-01-09
130130
depends_on:
131131
- test
132132
- test_bootstrapped
@@ -169,7 +169,7 @@ steps:
169169

170170
- name: publish_sbt_release
171171
pull: default
172-
image: lampepfl/dotty:2019-10-17
172+
image: lampepfl/dotty:2020-01-09
173173
depends_on:
174174
- test
175175
- test_bootstrapped

community-build/project/build.properties

-1
This file was deleted.

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ final case class SbtCommunityProject(project: String, sbtTestCommand: String,
100100
case Some(ivyHome) => List(s"-Dsbt.ivy.home=$ivyHome")
101101
case _ => Nil
102102
extraSbtArgs ++ sbtProps ++ List(
103-
"-sbt-version", "1.2.7",
103+
"-sbt-version", "1.3.6",
104104
s"--addPluginSbtFile=$sbtPluginFilePath")
105105

106106
object projects

project/Build.scala

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object Build {
6161
val referenceVersion = "0.21.0-RC1"
6262

6363
val baseVersion = "0.22.0"
64-
val baseSbtDottyVersion = "0.3.5"
64+
val baseSbtDottyVersion = "0.4.0"
6565

6666
// Versions used by the vscode extension to create a new project
6767
// This should be the latest published releases.
@@ -192,6 +192,11 @@ object Build {
192192
state
193193
},
194194

195+
// Turn off the sbt supershell because it can mangle the output of some tasks
196+
// (see https://github.com/sbt/sbt/issues/5122, https://github.com/sbt/sbt/issues/5352)
197+
// and in general I find it more distracting than helpful anyway.
198+
useSuperShell := false,
199+
195200
// Credentials to release to Sonatype
196201
credentials ++= (
197202
for {

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.7
1+
sbt.version=1.3.6

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

+31-45
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ object DottyPlugin extends AutoPlugin {
154154
override val globalSettings: Seq[Def.Setting[_]] = Seq(
155155
onLoad in Global := onLoad.in(Global).value.andThen { state =>
156156

157-
val requiredVersion = ">=1.2.7"
157+
val requiredVersion = ">=1.3.6"
158158

159159
val sbtV = sbtVersion.value
160160
if (!VersionNumber(sbtV).matchesSemVer(SemanticSelector(requiredVersion)))
@@ -210,41 +210,42 @@ object DottyPlugin extends AutoPlugin {
210210
scalaBinaryVersion.value
211211
},
212212

213-
// Ideally, we should have:
213+
// We want:
214214
//
215215
// 1. Nothing but the Java standard library on the _JVM_ bootclasspath
216216
// (starting with Java 9 we cannot inspect it so we don't have a choice)
217217
//
218-
// 2. scala-library, dotty-library, dotty-compiler, dotty-doc on the _JVM_
219-
// classpath, because we need all of those to actually run the compiler
220-
// and the doc tool.
218+
// 2. scala-library, dotty-library, dotty-compiler and its dependencies on the _JVM_
219+
// classpath, because we need all of those to actually run the compiler.
221220
// NOTE: All of those should have the *same version* (equal to scalaVersion
222221
// for everything but scala-library).
222+
// (Complication: because dottydoc is a separate artifact with its own dependencies,
223+
// running it requires putting extra dependencies on the _JVM_ classpath)
223224
//
224-
// 3. scala-library, dotty-library on the _compiler_ bootclasspath because
225-
// user code should always have access to the symbols from these jars but
226-
// should not be able to shadow them (the compiler bootclasspath has
227-
// higher priority than the compiler classpath).
225+
// 3. scala-library, dotty-library on the _compiler_ bootclasspath or
226+
// classpath (the only difference between them is that the compiler
227+
// bootclasspath has higher priority, but that should never
228+
// make a difference in a sane environment).
228229
// NOTE: the versions of {scala,dotty}-library used here do not necessarily
229230
// match the one used in 2. because a dependency of the current project might
230-
// require more recent versions, this is OK.
231+
// require a more recent standard library version, this is OK
232+
// TODO: ... but if macros are used we might be forced to use the same
233+
// versions in the JVM and compiler classpaths to avoid problems, this
234+
// needs to be investigated.
231235
//
232236
// 4. every other dependency of the user project on the _compiler_
233237
// classpath.
234238
//
235-
// Unfortunately, zinc assumes that the compiler bootclasspath is only
236-
// made of one jar (scala-library), so to make this work we'll need to
237-
// either change sbt's bootclasspath handling or wait until the
238-
// dotty-library jar and scala-library jars are merged into one jar.
239-
// Furthermore, zinc will put on the compiler bootclasspath the
239+
// By default, zinc will put on the compiler bootclasspath the
240240
// scala-library used on the JVM classpath, even if the current project
241241
// transitively depends on a newer scala-library (this works because Scala
242242
// 2 guarantees forward- and backward- binary compatibility, but we don't
243243
// necessarily want to keep doing that in Scala 3).
244244
// So for the moment, let's just put nothing at all on the compiler
245-
// bootclasspath, and instead have scala-library and dotty-library on the
246-
// compiler classpath. This means that user code could shadow symbols
247-
// from these jars but we can live with that for now.
245+
// bootclasspath, and instead let sbt dependency management choose which
246+
// scala-library and dotty-library to put on the compiler classpath.
247+
// Maybe eventually we should just remove the compiler bootclasspath since
248+
// it's a source of complication with only dubious benefits.
248249

249250
// sbt crazy scoping rules mean that when we override `classpathOptions`
250251
// below we also override `classpathOptions in console` which is normally
@@ -404,7 +405,7 @@ object DottyPlugin extends AutoPlugin {
404405

405406
/** Create a scalaInstance task that uses Dotty based on `moduleName`. */
406407
def dottyScalaInstanceTask(moduleName: String): Initialize[Task[ScalaInstance]] = Def.task {
407-
val ivyConfig0 = mkIvyConfiguration.value
408+
val ivyConfig0 = Classpaths.mkIvyConfiguration.value
408409
// When compiling non-bootstrapped projects in the build of Dotty itself,
409410
// dependency resolution might pick a local project which is not what we
410411
// want. We avoid this by dropping the inter-project resolver.
@@ -436,37 +437,22 @@ object DottyPlugin extends AutoPlugin {
436437
)
437438
}
438439

439-
// Copy-pasted from sbt until we upgrade to a version of sbt
440-
// with https://github.com/sbt/sbt/pull/5271 in.
441-
def mkIvyConfiguration: Initialize[Task[InlineIvyConfiguration]] =
442-
Def.task {
443-
val (rs, other) = (fullResolvers.value.toVector, otherResolvers.value.toVector)
444-
val s = streams.value
445-
Classpaths.warnResolversConflict(rs ++: other, s.log)
446-
InlineIvyConfiguration()
447-
.withPaths(ivyPaths.value)
448-
.withResolvers(rs)
449-
.withOtherResolvers(other)
450-
.withModuleConfigurations(moduleConfigurations.value.toVector)
451-
.withLock(Defaults.lock(appConfiguration.value))
452-
.withChecksums((checksums in update).value.toVector)
453-
.withResolutionCacheDir(crossTarget.value / "resolution-cache")
454-
.withUpdateOptions(updateOptions.value)
455-
.withLog(s.log)
456-
}
457-
440+
// Adapted from private mkScalaInstance in sbt
458441
def makeScalaInstance(
459442
state: State, dottyVersion: String, scalaLibrary: File, dottyLibrary: File, compiler: File, all: Seq[File]
460443
): ScalaInstance = {
461-
val loader = state.classLoaderCache(all.toList)
462-
val loaderLibraryOnly = state.classLoaderCache(List(dottyLibrary, scalaLibrary))
444+
val libraryLoader = state.classLoaderCache(List(dottyLibrary, scalaLibrary))
445+
class DottyLoader
446+
extends URLClassLoader(all.map(_.toURI.toURL).toArray, libraryLoader)
447+
val fullLoader = state.classLoaderCache.cachedCustomClassloader(
448+
all.toList,
449+
() => new DottyLoader
450+
)
463451
new ScalaInstance(
464452
dottyVersion,
465-
loader,
466-
loaderLibraryOnly,
467-
scalaLibrary, // Should be a Seq also containing dottyLibrary but zinc
468-
// doesn't support this, see comment above our redefinition
469-
// of `classpathOption`
453+
fullLoader,
454+
libraryLoader,
455+
Array(dottyLibrary, scalaLibrary),
470456
compiler,
471457
all.toArray,
472458
None)

0 commit comments

Comments
 (0)