@@ -32,6 +32,8 @@ import sbtbuildinfo.BuildInfoPlugin.autoImport._
32
32
import sbttastymima .TastyMiMaPlugin
33
33
import sbttastymima .TastyMiMaPlugin .autoImport ._
34
34
35
+ import scala .jdk .CollectionConverters ._
36
+
35
37
import scala .util .Properties .isJavaAtLeast
36
38
37
39
import org .portablescala .sbtplatformdeps .PlatformDepsPlugin .autoImport ._
@@ -1278,13 +1280,96 @@ object Build {
1278
1280
sources
1279
1281
} (Set (scalaLibrarySourcesJar)).toSeq
1280
1282
}.taskValue,
1283
+ (Compile / resourceGenerators) += Def .task {
1284
+ val s = streams.value
1285
+ val cacheDir = s.cacheDirectory
1286
+ val trgDir = (Compile / resourceManaged).value / " scala-library-classes"
1287
+ val report = update.value
1288
+
1289
+ val scalaLibraryBinaryJar = report.select(
1290
+ configuration = configurationFilter(),
1291
+ module = (_ : ModuleID ).name == " scala-library" ,
1292
+ artifact = artifactFilter(`type` = " jar" )).headOption.getOrElse {
1293
+ sys.error(s " Could not fetch scala-library binary JAR " )
1294
+ }
1295
+
1296
+ FileFunction .cached(cacheDir / s " fetchScalaLibraryClasses " ,
1297
+ FilesInfo .lastModified, FilesInfo .exists) { dependencies =>
1298
+ s.log.info(s " Unpacking scala-library binaries to $trgDir... " )
1299
+ if (trgDir.exists)
1300
+ IO .delete(trgDir)
1301
+ IO .createDirectory(trgDir)
1302
+ IO .unzip(scalaLibraryBinaryJar, trgDir)
1303
+
1304
+ (trgDir ** " *.class" ).get.toSet
1305
+ } (Set (scalaLibraryBinaryJar)).toSeq
1306
+ }.taskValue,
1281
1307
(Compile / sources) := {
1282
1308
val files = (Compile / sources).value
1283
1309
val overwrittenSourcesDir = (Compile / scalaSource).value
1284
1310
val overwrittenSources = files.flatMap(_.relativeTo(overwrittenSourcesDir)).toSet
1285
1311
val reference = (Compile / sourceManaged).value / " scala-library-src"
1286
1312
files.filterNot(_.relativeTo(reference).exists(overwrittenSources))
1287
1313
},
1314
+ (Compile / compile) := {
1315
+ val result = (Compile / compile).value
1316
+ println(" Generating the diff..." )
1317
+ val files = (Compile / resources).value
1318
+ val overwrittenSources = Files .walk((Compile / classDirectory).value.toPath())
1319
+ .iterator()
1320
+ .asScala
1321
+ .map(_.toFile)
1322
+ .map(_.relativeTo((Compile / classDirectory).value).get)
1323
+ .toSet
1324
+ val reference = (Compile / resourceManaged).value / " scala-library-classes"
1325
+ val diff = files.filterNot(_.relativeTo(reference).exists(overwrittenSources))
1326
+
1327
+ IO .copy(diff.map { file =>
1328
+ file -> (Compile / classDirectory).value / file.relativeTo(reference).get.getPath
1329
+ })
1330
+
1331
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " Tuple1.class" ), (Compile / classDirectory).value / " scala" / " Tuple1.class" )
1332
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " Tuple2.class" ), (Compile / classDirectory).value / " scala" / " Tuple2.class" )
1333
+
1334
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " collection" / " DoubleStepper.class" ), (Compile / classDirectory).value / " scala" / " collection" / " DoubleStepper.class" )
1335
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " collection" / " IntStepper.class" ), (Compile / classDirectory).value / " scala" / " collection" / " IntStepper.class" )
1336
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " collection" / " LongStepper.class" ), (Compile / classDirectory).value / " scala" / " collection" / " LongStepper.class" )
1337
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " collection" / " immutable" / " DoubleVectorStepper.class" ), (Compile / classDirectory).value / " scala" / " collection" / " immutable" / " DoubleVectorStepper.class" )
1338
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " collection" / " immutable" / " IntVectorStepper.class" ), (Compile / classDirectory).value / " scala" / " collection" / " immutable" / " IntVectorStepper.class" )
1339
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " collection" / " immutable" / " LongVectorStepper.class" ), (Compile / classDirectory).value / " scala" / " collection" / " immutable" / " LongVectorStepper.class" )
1340
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " DoubleAccumulator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " DoubleAccumulator.class" )
1341
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " IntAccumulator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " IntAccumulator.class" )
1342
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " LongAccumulator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " LongAccumulator.class" )
1343
+
1344
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaBooleanSupplier.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaBooleanSupplier.class" )
1345
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleBinaryOperator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleBinaryOperator.class" )
1346
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleConsumer.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleConsumer.class" )
1347
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaDoublePredicate.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaDoublePredicate.class" )
1348
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleSupplier.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleSupplier.class" )
1349
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleToIntFunction.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleToIntFunction.class" )
1350
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleToLongFunction.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleToLongFunction.class" )
1351
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleUnaryOperator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaDoubleUnaryOperator.class" )
1352
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaIntBinaryOperator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaIntBinaryOperator.class" )
1353
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaIntConsumer.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaIntConsumer.class" )
1354
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaIntPredicate.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaIntPredicate.class" )
1355
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaIntSupplier.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaIntSupplier.class" )
1356
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaIntToDoubleFunction.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaIntToDoubleFunction.class" )
1357
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaIntToLongFunction.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaIntToLongFunction.class" )
1358
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaIntUnaryOperator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaIntUnaryOperator.class" )
1359
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaLongBinaryOperator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaLongBinaryOperator.class" )
1360
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaLongConsumer.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaLongConsumer.class" )
1361
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaLongPredicate.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaLongPredicate.class" )
1362
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaLongSupplier.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaLongSupplier.class" )
1363
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaLongToDoubleFunction.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaLongToDoubleFunction.class" )
1364
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaLongToIntFunction.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaLongToIntFunction.class" )
1365
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " jdk" / " FunctionWrappers$FromJavaLongUnaryOperator.class" ), (Compile / classDirectory).value / " scala" / " jdk" / " FunctionWrappers$FromJavaLongUnaryOperator.class" )
1366
+
1367
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " collection" / " ArrayOps$ReverseIterator.class" ), (Compile / classDirectory).value / " scala" / " collection" / " ArrayOps$ReverseIterator.class" )
1368
+
1369
+ IO .copyFile(((Compile / resourceManaged).value / " scala-library-classes" / " scala" / " runtime" / " NonLocalReturnControl.class" ), (Compile / classDirectory).value / " scala" / " runtime" / " NonLocalReturnControl.class" )
1370
+
1371
+ result
1372
+ },
1288
1373
(Test / managedClasspath) ~= {
1289
1374
_.filterNot(file => file.data.getName == s " scala-library- $stdlibBootstrappedVersion.jar " )
1290
1375
},
0 commit comments