@@ -13,6 +13,7 @@ import java.util.Optional
13
13
import scala .util .Properties .isJavaAtLeast
14
14
15
15
object DottyPlugin extends AutoPlugin {
16
+ val dottyScalaInstance = taskKey[ScalaInstance ](" ScalaInstance for Dotty" )
16
17
object autoImport {
17
18
val isDotty = settingKey[Boolean ](" Is this project compiled with Dotty?" )
18
19
@@ -142,6 +143,8 @@ object DottyPlugin extends AutoPlugin {
142
143
}
143
144
)
144
145
146
+ // https://github.com/sbt/sbt/issues/3110
147
+ val Def = sbt.Def
145
148
override def projectSettings : Seq [Setting [_]] = {
146
149
Seq (
147
150
isDotty := scalaVersion.value.startsWith(" 0." ),
@@ -266,41 +269,39 @@ object DottyPlugin extends AutoPlugin {
266
269
},
267
270
// ... instead, we'll fetch the compiler and its dependencies ourselves.
268
271
scalaInstance := Def .taskDyn {
269
- if (isDotty.value) Def .task {
270
- val updateReport =
271
- fetchArtifactsOf(
272
- dependencyResolution.value,
273
- scalaModuleInfo.value,
274
- updateConfiguration.value,
275
- (unresolvedWarningConfiguration in update).value,
276
- streams.value.log,
277
- scalaOrganization.value %% " dotty-doc" % scalaVersion.value)
278
- val scalaLibraryJar = getJar(updateReport,
279
- " org.scala-lang" , " scala-library" , revision = AllPassFilter )
280
- val dottyLibraryJar = getJar(updateReport,
281
- scalaOrganization.value, s " dotty-library_ ${scalaBinaryVersion.value}" , scalaVersion.value)
282
- val compilerJar = getJar(updateReport,
283
- scalaOrganization.value, s " dotty-compiler_ ${scalaBinaryVersion.value}" , scalaVersion.value)
284
- val allJars =
285
- getJars(updateReport, AllPassFilter , AllPassFilter , AllPassFilter )
286
-
287
- makeScalaInstance(
288
- state.value,
289
- scalaVersion.value,
290
- scalaLibraryJar,
291
- dottyLibraryJar,
292
- compilerJar,
293
- allJars
294
- )
295
- }
296
- else Def .task {
297
- // This should really be `old` with `val old = scalaInstance.value`
298
- // above, except that this would force the original definition of the
299
- // `scalaInstance` task to be computed when `isDotty` is true, which
300
- // would fail because `managedScalaInstance` is false.
301
- Defaults .scalaInstanceTask.value
302
- }
272
+ val isD = isDotty.value
273
+ val si = scalaInstance.taskValue
274
+ val siTaskInitialize = Def .valueStrict { si }
275
+ if (isD) dottyScalaInstance
276
+ else siTaskInitialize
303
277
}.value,
278
+ dottyScalaInstance := {
279
+ val updateReport =
280
+ fetchArtifactsOf(
281
+ dependencyResolution.value,
282
+ scalaModuleInfo.value,
283
+ updateConfiguration.value,
284
+ (unresolvedWarningConfiguration in update).value,
285
+ streams.value.log,
286
+ scalaOrganization.value %% " dotty-doc" % scalaVersion.value)
287
+ val scalaLibraryJar = getJar(updateReport,
288
+ " org.scala-lang" , " scala-library" , revision = AllPassFilter )
289
+ val dottyLibraryJar = getJar(updateReport,
290
+ scalaOrganization.value, s " dotty-library_ ${scalaBinaryVersion.value}" , scalaVersion.value)
291
+ val compilerJar = getJar(updateReport,
292
+ scalaOrganization.value, s " dotty-compiler_ ${scalaBinaryVersion.value}" , scalaVersion.value)
293
+ val allJars =
294
+ getJars(updateReport, AllPassFilter , AllPassFilter , AllPassFilter )
295
+
296
+ makeScalaInstance(
297
+ state.value,
298
+ scalaVersion.value,
299
+ scalaLibraryJar,
300
+ dottyLibraryJar,
301
+ compilerJar,
302
+ allJars
303
+ )
304
+ },
304
305
305
306
// Because managedScalaInstance is false, sbt won't add the standard library to our dependencies for us
306
307
libraryDependencies ++= {
0 commit comments