@@ -11,7 +11,11 @@ object ScalaLibraryPlugin extends AutoPlugin {
11
11
12
12
override def trigger = noTrigger
13
13
14
+ private val scala2Version = " 2.13.16"
15
+ private val scalaJSVersion = " 1.19.0"
16
+
14
17
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" )
15
19
16
20
override def projectSettings = Seq (
17
21
fetchScala2ClassFiles := {
@@ -37,6 +41,31 @@ object ScalaLibraryPlugin extends AutoPlugin {
37
41
(target ** " *.class" ).get.toSet
38
42
} (Set (scalaLibraryBinaryJar)), target)
39
43
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
+
40
69
},
41
70
(Compile / manipulateBytecode) := {
42
71
val stream = streams.value
0 commit comments