@@ -11,7 +11,11 @@ object ScalaLibraryPlugin extends AutoPlugin {
1111
1212 override def trigger = noTrigger
1313
14+ private val scala2Version = " 2.13.16"
15+ private val scalaJSVersion = " 1.19.0"
16+
1417 val fetchScala2ClassFiles = taskKey[(Set [File ], File )](" Fetch the files to use that were compiled with Scala 2" )
18+ val fetchScala2SJSIR = taskKey[(Set [File ], File )](" Fetch the .sjsir to use from Scala 2" )
1519
1620 override def projectSettings = Seq (
1721 fetchScala2ClassFiles := {
@@ -37,6 +41,31 @@ object ScalaLibraryPlugin extends AutoPlugin {
3741 (target ** " *.class" ).get.toSet
3842 } (Set (scalaLibraryBinaryJar)), target)
3943
44+ },
45+ fetchScala2SJSIR := {
46+ val stream = streams.value
47+ val lm = dependencyResolution.value
48+ val log = stream.log
49+ val cache = stream.cacheDirectory
50+ val retrieveDir = cache / " scalajs-scalalib" / scalaVersion.value
51+ val comp = lm.retrieve(" org.scala-js" % " scalajs-scalalib_2.13" % s " $scala2Version+ $scalaJSVersion" , scalaModuleInfo = None , retrieveDir, log)
52+ .fold(w => throw w.resolveException, identity)
53+
54+ println(comp(0 ))
55+
56+ val target = cache / " scala-library-sjsir"
57+
58+
59+ if (! target.exists()) {
60+ IO .createDirectory(target)
61+ }
62+
63+ (FileFunction .cached(cache / " fetch-scala-library-sjsir" , FilesInfo .lastModified, FilesInfo .exists) { _ =>
64+ stream.log.info(s " Unpacking scalajs-scalalib binaries to persistent directory: ${target.getAbsolutePath}" )
65+ IO .unzip(comp(0 ), target)
66+ (target ** " *.sjsir" ).get.toSet
67+ } (Set (comp(0 ))), target)
68+
4069 },
4170 (Compile / manipulateBytecode) := {
4271 val stream = streams.value
0 commit comments