@@ -1050,6 +1050,49 @@ object Build {
1050
1050
(Test / managedClasspath) ~= {
1051
1051
_.filterNot(file => file.data.getName == s " scala-library- ${stdlibVersion(Bootstrapped )}.jar " )
1052
1052
},
1053
+ run := {
1054
+ val args : Seq [String ] = spaceDelimited(" <arg>" ).parsed
1055
+ val srcDir = (Compile / scalaSource).value
1056
+ val reference = (Compile / sourceManaged).value / " scala-library-src"
1057
+ args match {
1058
+ case Seq (" list" ) =>
1059
+ println(s " List of non-overriden files in $reference" )
1060
+ reference.allPaths.get()
1061
+ .flatMap(_.relativeTo(reference))
1062
+ .filter(_.ext == " scala" )
1063
+ .sorted
1064
+ .foreach(println)
1065
+ case Seq (cmd @ (" clone" | " overwrite" ), files* ) =>
1066
+ println(" Cloning scala-library sources: " + files.mkString(" , " ))
1067
+ for (file <- files) {
1068
+ val referenceStdlibPaths = reference / file
1069
+ val destination = srcDir / file
1070
+ if (! referenceStdlibPaths.exists) {
1071
+ println(" Not found " + referenceStdlibPaths)
1072
+ } else if (destination.exists && cmd == " clone" ) {
1073
+ println(s " Already exists $file. (use `overwrite` command to overwrite) " )
1074
+ } else {
1075
+ val action = if (cmd == " clone" ) " Cloning" else " Overwriting"
1076
+ println(s " $action $file" )
1077
+ IO .copyFile(referenceStdlibPaths, destination)
1078
+ }
1079
+ }
1080
+ case _ =>
1081
+ val projectName = projectInfo.value.nameFormal
1082
+ println(
1083
+ s """ Usage:
1084
+ |> $projectName/run list
1085
+ | -- lists all files that are not overriden in stdlib-bootstrapped/src
1086
+ |
1087
+ |> $projectName/run clone <sources>*
1088
+ | -- clones the specified sources from the stdlib-bootstrapped/src
1089
+ | -- example: $projectName/run clone scala/Option.scala
1090
+ |
1091
+ |> $projectName/run overwrite <sources>*
1092
+ | -- (danger) overwrites the specified sources from the stdlib-bootstrapped/src
1093
+ | """ .stripMargin)
1094
+ }
1095
+ }
1053
1096
)
1054
1097
1055
1098
/** Creates a copy of the Scala 2.13 library JAR with TASTy from `stdlib-2_13-bootstrapped` */
0 commit comments