@@ -16,6 +16,7 @@ import xerial.sbt.pack.PackPlugin
16
16
import xerial .sbt .pack .PackPlugin .autoImport ._
17
17
18
18
import dotty .tools .sbtplugin .DottyPlugin .autoImport ._
19
+ import dotty .tools .sbtplugin .DottyPlugin .makeScalaInstance
19
20
import dotty .tools .sbtplugin .DottyIDEPlugin .{ installCodeExtension , prepareCommand , runProcess }
20
21
import dotty .tools .sbtplugin .DottyIDEPlugin .autoImport ._
21
22
@@ -27,20 +28,11 @@ import sbtbuildinfo.BuildInfoPlugin.autoImport._
27
28
28
29
import scala .util .Properties .isJavaAtLeast
29
30
30
- /* In sbt 0.13 the Build trait would expose all vals to the shell, where you
31
- * can use them in "set a := b" like expressions. This re-exposes them.
32
- */
33
- object ExposedValues extends AutoPlugin {
34
- object autoImport {
35
- val bootstrapFromPublishedJars = Build .bootstrapFromPublishedJars
36
- }
37
- }
38
-
39
31
object Build {
40
32
val scalacVersion = " 2.12.8"
41
33
42
34
val baseVersion = " 0.13.0"
43
- val baseSbtDottyVersion = " 0.2.7 "
35
+ val baseSbtDottyVersion = " 0.3.1 "
44
36
45
37
// Versions used by the vscode extension to create a new project
46
38
// This should be the latest published releases.
@@ -100,8 +92,6 @@ object Build {
100
92
// Shorthand for compiling a docs site
101
93
val dottydoc = inputKey[Unit ](" run dottydoc" )
102
94
103
- val bootstrapFromPublishedJars = settingKey[Boolean ](" If true, bootstrap dotty from published non-bootstrapped dotty" )
104
-
105
95
// Only available in vscode-dotty
106
96
val unpublish = taskKey[Unit ](" Unpublish a package" )
107
97
@@ -129,9 +119,6 @@ object Build {
129
119
130
120
javacOptions in (Compile , compile) ++= Seq (" -Xlint:unchecked" , " -Xlint:deprecation" ),
131
121
132
- // Change this to true if you want to bootstrap using a published non-bootstrapped compiler
133
- bootstrapFromPublishedJars := false ,
134
-
135
122
// Override `runCode` from sbt-dotty to use the language-server and
136
123
// vscode extension from the source repository of dotty instead of a
137
124
// published version.
@@ -220,20 +207,6 @@ object Build {
220
207
// Use the same name as the non-bootstrapped projects for the artifacts
221
208
moduleName ~= { _.stripSuffix(" -bootstrapped" ) },
222
209
223
- // Prevent sbt from setting the Scala bootclasspath, otherwise it will
224
- // contain `scalaInstance.value.libraryJar` which in our case is the
225
- // non-bootstrapped dotty-library that will then take priority over
226
- // the bootstrapped dotty-library on the classpath or sourcepath.
227
- classpathOptions ~= (_.withAutoBoot(false )),
228
- // ... but when running under Java 8, we still need a Scala bootclasspath that contains the JVM bootclasspath,
229
- // otherwise sbt incremental compilation breaks.
230
- scalacOptions ++= {
231
- if (isJavaAtLeast(" 9" ))
232
- Seq ()
233
- else
234
- Seq (" -bootclasspath" , sys.props(" sun.boot.class.path" ))
235
- },
236
-
237
210
// Enforce that the only Scala 2 classfiles we unpickle come from scala-library
238
211
/*
239
212
scalacOptions ++= {
@@ -251,64 +224,31 @@ object Build {
251
224
// ...but scala-library is
252
225
libraryDependencies += " org.scala-lang" % " scala-library" % scalacVersion,
253
226
254
- ivyConfigurations ++= {
255
- if (bootstrapFromPublishedJars.value)
256
- Seq (Configurations .ScalaTool )
257
- else
258
- Seq ()
259
- },
260
- libraryDependencies ++= {
261
- if (bootstrapFromPublishedJars.value)
262
- Seq (
263
- dottyOrganization %% " dotty-library" % dottyNonBootstrappedVersion % Configurations .ScalaTool .name,
264
- dottyOrganization %% " dotty-compiler" % dottyNonBootstrappedVersion % Configurations .ScalaTool .name
265
- ).map(_.withDottyCompat(scalaVersion.value))
266
- else
267
- Seq ()
268
- },
269
-
270
227
// Compile using the non-bootstrapped and non-published dotty
271
228
managedScalaInstance := false ,
272
229
scalaInstance := {
273
- import sbt .internal .inc .ScalaInstance
274
- import sbt .internal .inc .classpath .ClasspathUtilities
275
-
276
- val updateReport = update.value
277
- var libraryJar = packageBin.in(`dotty-library`, Compile ).value
278
- var compilerJar = packageBin.in(`dotty-compiler`, Compile ).value
279
-
280
- if (bootstrapFromPublishedJars.value) {
281
- val jars = updateReport.select(
282
- configuration = configurationFilter(Configurations .ScalaTool .name),
283
- module = moduleFilter(),
284
- artifact = artifactFilter(extension = " jar" )
285
- )
286
- libraryJar = jars.find(_.getName.startsWith(" dotty-library_2.12" )).get
287
- compilerJar = jars.find(_.getName.startsWith(" dotty-compiler_2.12" )).get
288
- }
289
-
290
- // All dotty-doc's and compiler's dependencies except the library.
291
- // (we get the compiler's dependencies because dottydoc depends on the compiler)
292
- val otherDependencies = {
293
- val excluded = Set (" dotty-library" , " dotty-compiler" )
294
- fullClasspath.in(`dotty-doc`, Compile ).value
295
- .filterNot(_.get(artifact.key).exists(a => excluded.contains(a.name)))
296
- .map(_.data)
297
- }
298
-
299
- val allJars = libraryJar :: compilerJar :: otherDependencies.toList
300
- val classLoader = state.value.classLoaderCache(allJars)
301
- new ScalaInstance (
230
+ // TODO: Here we use the output class directories directly, this might impact
231
+ // performance when running the compiler (especially on Windows where file
232
+ // IO is slow). We should benchmark whether using jars is actually faster
233
+ // in practice (especially on our CI), this could be done using
234
+ // `exportJars := true`.
235
+ val all = fullClasspath.in(`dotty-doc`, Compile ).value
236
+ def getArtifact (name : String ): File =
237
+ all.find(_.get(artifact.key).exists(_.name == name))
238
+ .getOrElse(throw new MessageOnlyException (s " Artifact for $name not found in $all" ))
239
+ .data
240
+
241
+ val scalaLibrary = getArtifact(" scala-library" )
242
+ val dottyLibrary = getArtifact(" dotty-library" )
243
+ val compiler = getArtifact(" dotty-compiler" )
244
+
245
+ makeScalaInstance(
246
+ state.value,
302
247
scalaVersion.value,
303
- classLoader,
304
- ClasspathUtilities .rootLoader, // FIXME: Should be a class loader which only includes the dotty-lib
305
- // See: https://github.com/sbt/zinc/commit/9397b6aaf94ac3cfab386e3abd11c0ef9c2ceaff#diff-ea135f2f26f43e40ff045089da221e1e
306
- // Should not matter, as it addresses an issue with `sbt run` that
307
- // only occur when `(fork in run) := false`
308
- libraryJar,
309
- compilerJar,
310
- allJars.toArray,
311
- None
248
+ scalaLibrary,
249
+ dottyLibrary,
250
+ compiler,
251
+ all.map(_.data)
312
252
)
313
253
}
314
254
)
@@ -334,11 +274,6 @@ object Build {
334
274
335
275
/** Projects -------------------------------------------------------------- */
336
276
337
- // Needed because the dotty project aggregates dotty-sbt-bridge but dotty-sbt-bridge
338
- // currently refers to dotty in its scripted task and "aggregate" does not take by-name
339
- // parameters: https://github.com/sbt/sbt/issues/2200
340
- lazy val dottySbtBridgeRef = LocalProject (" dotty-sbt-bridge" )
341
-
342
277
// The root project:
343
278
// - aggregates other projects so that "compile", "test", etc are run on all projects at once.
344
279
// - publishes its own empty artifact "dotty" that depends on "dotty-library" and "dotty-compiler",
0 commit comments