@@ -227,28 +227,33 @@ object Build {
227
227
// Compile using the non-bootstrapped and non-published dotty
228
228
managedScalaInstance := false ,
229
229
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" ))
230
+ val externalDeps = externalDependencyClasspath.in(`dotty-doc`, Compile ).value
231
+ def getExternalDep (name : String ): File =
232
+ externalDeps.find(_.get(artifact.key).exists(_.name == name))
233
+ .getOrElse(throw new MessageOnlyException (s " Artifact for $name not found in $externalDeps" ))
239
234
.data
240
235
241
- val scalaLibrary = getArtifact(" scala-library" )
242
- val dottyLibrary = getArtifact(" dotty-library" )
243
- val compiler = getArtifact(" dotty-compiler" )
236
+ val scalaLibrary = getExternalDep(" scala-library" )
237
+
238
+ // IMPORTANT: We need to use actual jars to form the ScalaInstance and not
239
+ // just directories containing classfiles because sbt maintains a cache of
240
+ // compiler instances. This cache is invalidated based on timestamps
241
+ // however this is only implemented on jars, directories are never
242
+ // invalidated.
243
+ val dottyLibrary = packageBin.in(`dotty-library`, Compile ).value
244
+ val dottyInterfaces = packageBin.in(`dotty-interfaces`, Compile ).value
245
+ val dottyCompiler = packageBin.in(`dotty-compiler`, Compile ).value
246
+ val dottyDoc = packageBin.in(`dotty-doc`, Compile ).value
247
+
248
+ val allJars = Seq (dottyLibrary, dottyInterfaces, dottyCompiler, dottyDoc) ++ externalDeps.map(_.data)
244
249
245
250
makeScalaInstance(
246
251
state.value,
247
252
scalaVersion.value,
248
253
scalaLibrary,
249
254
dottyLibrary,
250
- compiler ,
251
- all.map(_.data)
255
+ dottyCompiler ,
256
+ allJars
252
257
)
253
258
}
254
259
)
0 commit comments