@@ -267,7 +267,7 @@ object Build {
267
267
/*
268
268
scalacOptions ++= {
269
269
val cp = (dependencyClasspath in `dotty-library` in Compile).value
270
- val scalaLib = findLib (cp, "scala-library")
270
+ val scalaLib = findArtifactPath (cp, "scala-library")
271
271
Seq("-Yscala2-unpickler", scalaLib)
272
272
},
273
273
*/
@@ -279,12 +279,7 @@ object Build {
279
279
managedScalaInstance := false ,
280
280
scalaInstance := {
281
281
val externalNonBootstrappedDeps = externalDependencyClasspath.in(`dotty-doc`, Compile ).value
282
- def getExternalDep (name : String ): File =
283
- externalNonBootstrappedDeps.find(_.get(artifact.key).exists(_.name == name))
284
- .getOrElse(throw new MessageOnlyException (s " Artifact for $name not found in $externalNonBootstrappedDeps" ))
285
- .data
286
-
287
- val scalaLibrary = getExternalDep(" scala-library" )
282
+ val scalaLibrary = findArtifact(externalNonBootstrappedDeps, " scala-library" )
288
283
289
284
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
290
285
// just directories containing classfiles because sbt maintains a cache of
@@ -357,7 +352,7 @@ object Build {
357
352
val dottyInterfaces = jars(" dotty-interfaces" )
358
353
val otherDeps = (dependencyClasspath in Compile ).value.map(_.data).mkString(File .pathSeparator)
359
354
val externalDeps = externalCompilerClasspathTask.value
360
- dottyLib + File .pathSeparator + findLib (externalDeps, " scala-library- " )
355
+ dottyLib + File .pathSeparator + findArtifactPath (externalDeps, " scala-library" )
361
356
}
362
357
363
358
def dottyDocSettings (implicit mode : Mode ) = Seq (
@@ -426,10 +421,15 @@ object Build {
426
421
case Bootstrapped => `dotty-doc-bootstrapped`
427
422
}
428
423
429
- def findLib (classpath : Def .Classpath , name : String ) = classpath
430
- .map(_.data.getAbsolutePath)
431
- .find(_.contains(name))
432
- .toList.mkString(File .pathSeparator)
424
+ /** Find an artifact with the given `name` in `classpath` */
425
+ def findArtifact (classpath : Def .Classpath , name : String ): File = classpath
426
+ .find(_.get(artifact.key).exists(_.name == name))
427
+ .getOrElse(throw new MessageOnlyException (s " Artifact for $name not found in $classpath" ))
428
+ .data
429
+
430
+ /** Like `findArtifact` but returns the absolute path of the entry as a string */
431
+ def findArtifactPath (classpath : Def .Classpath , name : String ): String =
432
+ findArtifact(classpath, name).getAbsolutePath
433
433
434
434
// Settings shared between dotty-compiler and dotty-compiler-bootstrapped
435
435
lazy val commonDottyCompilerSettings = Seq (
@@ -517,11 +517,11 @@ object Build {
517
517
" -Ddotty.tests.classes.dottyInterfaces=" + jars(" dotty-interfaces" ),
518
518
" -Ddotty.tests.classes.dottyLibrary=" + jars(" dotty-library" ),
519
519
" -Ddotty.tests.classes.dottyCompiler=" + jars(" dotty-compiler" ),
520
- " -Ddotty.tests.classes.compilerInterface=" + findLib (externalDeps, " compiler-interface" ),
521
- " -Ddotty.tests.classes.scalaLibrary=" + findLib (externalDeps, " scala-library- " ),
522
- " -Ddotty.tests.classes.scalaAsm=" + findLib (externalDeps, " scala-asm" ),
523
- " -Ddotty.tests.classes.jlineTerminal=" + findLib (externalDeps, " jline-terminal" ),
524
- " -Ddotty.tests.classes.jlineReader=" + findLib (externalDeps, " jline-reader" )
520
+ " -Ddotty.tests.classes.compilerInterface=" + findArtifactPath (externalDeps, " compiler-interface" ),
521
+ " -Ddotty.tests.classes.scalaLibrary=" + findArtifactPath (externalDeps, " scala-library" ),
522
+ " -Ddotty.tests.classes.scalaAsm=" + findArtifactPath (externalDeps, " scala-asm" ),
523
+ " -Ddotty.tests.classes.jlineTerminal=" + findArtifactPath (externalDeps, " jline-terminal" ),
524
+ " -Ddotty.tests.classes.jlineReader=" + findArtifactPath (externalDeps, " jline-reader" )
525
525
)
526
526
527
527
jarOpts ::: tuning ::: agentOptions ::: ci_build
@@ -562,7 +562,7 @@ object Build {
562
562
val externalDeps = externalCompilerClasspathTask.value
563
563
val jars = packageAll.value
564
564
565
- val scalaLib = findLib (externalDeps, " scala-library" )
565
+ val scalaLib = findArtifactPath (externalDeps, " scala-library" )
566
566
val dottyLib = jars(" dotty-library" )
567
567
568
568
def run (args : List [String ]): Unit = {
@@ -576,7 +576,7 @@ object Build {
576
576
println(" Couldn't find scala-library on classpath, please run using script in bin dir instead" )
577
577
} else if (args.contains(" -with-compiler" )) {
578
578
val args1 = args.filter(_ != " -with-compiler" )
579
- val asm = findLib (externalDeps, " scala-asm" )
579
+ val asm = findArtifactPath (externalDeps, " scala-asm" )
580
580
val dottyCompiler = jars(" dotty-compiler" )
581
581
val dottyInterfaces = jars(" dotty-interfaces" )
582
582
run(insertClasspathInArgs(args1, List (dottyCompiler, dottyInterfaces, asm).mkString(File .pathSeparator)))
@@ -626,7 +626,7 @@ object Build {
626
626
val log = streams.value.log
627
627
val externalDeps = externalCompilerClasspathTask.value
628
628
val jars = packageAll.value
629
- val scalaLib = findLib (externalDeps, " scala-library- " )
629
+ val scalaLib = findArtifactPath (externalDeps, " scala-library" )
630
630
val dottyLib = jars(" dotty-library" )
631
631
val dottyCompiler = jars(" dotty-compiler" )
632
632
val args0 : List [String ] = spaceDelimited(" <arg>" ).parsed.toList
@@ -652,7 +652,7 @@ object Build {
652
652
log.error(" -with-compiler should only be used with a bootstrapped compiler" )
653
653
}
654
654
val dottyInterfaces = jars(" dotty-interfaces" )
655
- val asm = findLib (externalDeps, " scala-asm" )
655
+ val asm = findArtifactPath (externalDeps, " scala-asm" )
656
656
extraClasspath ++= Seq (dottyCompiler, dottyInterfaces, asm)
657
657
}
658
658
0 commit comments