@@ -197,7 +197,7 @@ object MyScalaJSPlugin extends AutoPlugin {
197
197
*/
198
198
libraryDependencies ~= { libDeps =>
199
199
val blacklist =
200
- Set (" scalajs-compiler" , " scalajs-library" , " scalajs-test-bridge" )
200
+ Set (" scalajs-compiler" , " scalajs-library" , " scalajs-scalalib " , " scalajs- test-bridge" )
201
201
libDeps.filterNot(dep => blacklist.contains(dep.name))
202
202
},
203
203
@@ -638,7 +638,7 @@ object Build {
638
638
* - `"semver-spec"` for artifacts whose public API can only break in major releases (e.g., `library`)
639
639
*
640
640
* At the moment, we only set the version scheme for artifacts in the
641
- * "library ecosystem", i.e., scalajs-javalib scalajs-library,
641
+ * "library ecosystem", i.e., scalajs-javalib, scalajs-scalalib, scalajs-library,
642
642
* scalajs-test-interface, scalajs-junit-runtime and scalajs-test-bridge.
643
643
* Artifacts of the "tools ecosystem" do not have a version scheme set, as
644
644
* the jury is still out on what is the best way to specify them.
@@ -749,17 +749,17 @@ object Build {
749
749
}
750
750
}
751
751
752
- /** Depends on library and, by artificial transitivity, on the javalib. */
752
+ /** Depends on library and, by artificial transitivity, on the javalib and scalalib . */
753
753
def dependsOnLibrary2_12 : Project = {
754
754
val library = LocalProject (" library2_12" )
755
755
756
756
// Add a real dependency on the library
757
757
val project1 = project
758
758
.dependsOn(library)
759
759
760
- /* Because the javalib's exportsJar is false, but its actual products are
761
- * only in its jar, we must manually add the jar on the internal
762
- * classpath.
760
+ /* Because the javalib's and scalalib's exportsJar is false, but their
761
+ * actual products are only in their jar, we must manually add the jars
762
+ * on the internal classpath.
763
763
* Once published, only jars are ever used, so this is fine.
764
764
*/
765
765
if (isGeneratingForIDE) {
@@ -772,6 +772,12 @@ object Build {
772
772
Test / internalDependencyClasspath +=
773
773
(javalib / Compile / packageBin).value,
774
774
)
775
+ .settings(
776
+ Compile / internalDependencyClasspath +=
777
+ (scalalib.v2_12 / Compile / packageBin).value,
778
+ Test / internalDependencyClasspath +=
779
+ (scalalib.v2_12 / Compile / packageBin).value,
780
+ )
775
781
}
776
782
}
777
783
@@ -818,28 +824,36 @@ object Build {
818
824
}
819
825
}
820
826
821
- /** Depends on library and, by transitivity, on the javalib. */
827
+ /** Depends on library and, by artificial transitivity, on the javalib and scalalib . */
822
828
def dependsOnLibrary : MultiScalaProject = {
823
829
// Add a real dependency on the library
824
830
val project1 = project
825
831
.dependsOn(library)
826
832
827
- /* Because the javalib's exportsJar is false, but its actual products are
828
- * only in its jar, we must manually add the jar on the internal
829
- * classpath.
833
+ /* Because the javalib's and scalalib's exportsJar is false, but their
834
+ * actual products are only in their jar, we must manually add the jars
835
+ * on the internal classpath.
830
836
* Once published, only jars are ever used, so this is fine.
831
837
*/
832
838
if (isGeneratingForIDE) {
833
839
project1
834
840
} else {
835
- // Actually add classpath dependencies on the javalib jar
841
+ // Actually add classpath dependencies on the javalib and scalalib jars
836
842
project1
837
843
.settings(
838
844
Compile / internalDependencyClasspath +=
839
845
(javalib / Compile / packageBin).value,
840
846
Test / internalDependencyClasspath +=
841
847
(javalib / Compile / packageBin).value,
842
848
)
849
+ .zippedSettings(scalalib) { scalalib =>
850
+ Def .settings(
851
+ Compile / internalDependencyClasspath +=
852
+ (scalalib / Compile / packageBin).value,
853
+ Test / internalDependencyClasspath +=
854
+ (scalalib / Compile / packageBin).value,
855
+ )
856
+ }
843
857
}
844
858
}
845
859
@@ -919,7 +933,7 @@ object Build {
919
933
linkerInterface, linkerInterfaceJS, linker, linkerJS,
920
934
testAdapter,
921
935
javalibintf,
922
- javalibInternal, javalib, scalalib , libraryAux, library,
936
+ javalibInternal, javalib, scalalibInternal , libraryAux, scalalib , library,
923
937
testInterface, jUnitRuntime, testBridge, jUnitPlugin, jUnitAsyncJS,
924
938
jUnitAsyncJVM, jUnitTestOutputsJS, jUnitTestOutputsJVM,
925
939
helloworld, reversi, testingExample, testSuite, testSuiteJVM,
@@ -1358,12 +1372,14 @@ object Build {
1358
1372
// JS libs
1359
1373
publishLocal in javalib,
1360
1374
1375
+ publishLocal in scalalib.v2_12,
1361
1376
publishLocal in library.v2_12,
1362
1377
publishLocal in testInterface.v2_12,
1363
1378
publishLocal in testBridge.v2_12,
1364
1379
publishLocal in jUnitRuntime.v2_12,
1365
1380
publishLocal in irProjectJS.v2_12,
1366
1381
1382
+ publishLocal in scalalib.v2_13,
1367
1383
publishLocal in library.v2_13,
1368
1384
publishLocal in testInterface.v2_13,
1369
1385
publishLocal in testBridge.v2_13,
@@ -1478,7 +1494,7 @@ object Build {
1478
1494
* copied from `javalibInternal`.
1479
1495
*
1480
1496
* This the "public" version of the javalib, as depended on by the `library`
1481
- * and published on Maven.
1497
+ * and `scalalib`, and published on Maven.
1482
1498
*/
1483
1499
lazy val javalib : Project = Project (
1484
1500
id = " javalib" , base = file(" javalib-public" )
@@ -1506,8 +1522,13 @@ object Build {
1506
1522
},
1507
1523
)
1508
1524
1509
- lazy val scalalib : MultiScalaProject = MultiScalaProject (
1510
- id = " scalalib" , base = file(" scalalib" )
1525
+ /** The project that actually compiles the `scalalib`, but which is not
1526
+ * exposed.
1527
+ *
1528
+ * Instead, its products are copied in `scalalib`.
1529
+ */
1530
+ lazy val scalalibInternal : MultiScalaProject = MultiScalaProject (
1531
+ id = " scalalibInternal" , base = file(" scalalib" )
1511
1532
).enablePlugins(
1512
1533
MyScalaJSPlugin
1513
1534
).settings(
@@ -1523,7 +1544,7 @@ object Build {
1523
1544
s " https://raw.githubusercontent.com/scala/scala/v ${scalaVersion.value}/src/library/ " )
1524
1545
option ++ prev
1525
1546
},
1526
- name := " Scala library for Scala.js " ,
1547
+ name := " scalajs-scalalib-internal " ,
1527
1548
publishArtifact in Compile := false ,
1528
1549
NoIDEExport .noIDEExportSettings,
1529
1550
delambdafySetting,
@@ -1669,12 +1690,54 @@ object Build {
1669
1690
recompileAllOrNothingSettings,
1670
1691
).withScalaJSCompiler.dependsOnLibraryNoJar
1671
1692
1693
+ /** An empty project, without source nor dependencies (other than the javalib),
1694
+ * whose products are copied from `scalalibInternal` and `libraryAux`.
1695
+ *
1696
+ * This the "public" version of the scalalib, as depended on by the `library`
1697
+ * and published on Maven.
1698
+ */
1699
+ lazy val scalalib : MultiScalaProject = MultiScalaProject (
1700
+ id = " scalalib" , base = file(" scalalib-public" )
1701
+ ).dependsOn(
1702
+ javalib,
1703
+ ).settings(
1704
+ commonSettings,
1705
+ name := " scalajs-scalalib" ,
1706
+ publishSettings(Some (VersionScheme .BreakOnMajor )),
1707
+
1708
+ /* The scalalib has a special version number that encodes both the Scala
1709
+ * version and the Scala.js version. This allows us to back-publish for
1710
+ * newer versions of Scala and older versions of Scala.js. The Scala
1711
+ * version comes first so that Ivy resolution will choose 2.13.20+1.15.0
1712
+ * over 2.13.18+1.16.0. The former might not be as optimized as the
1713
+ * latter, but at least it will contain all the binary API that might be
1714
+ * required.
1715
+ */
1716
+ version := scalaVersion.value + " +" + scalaJSVersion,
1717
+
1718
+ exportJars := false , // very important, otherwise there's a cycle with the `library`
1719
+ ).zippedSettings(Seq (" scalalibInternal" , " libraryAux" ))(localProjects =>
1720
+ inConfig(Compile )(Seq (
1721
+ // Use the .sjsir files from scalalibInternal and libraryAux (but not the .class files)
1722
+ Compile / packageBin / mappings := {
1723
+ val scalalibInternalMappings = (localProjects(0 ) / packageBin / mappings).value
1724
+ val libraryAuxMappings = (localProjects(1 ) / packageBin / mappings).value
1725
+ val allMappings = scalalibInternalMappings ++ libraryAuxMappings
1726
+ allMappings.filter(_._2.endsWith(" .sjsir" ))
1727
+ },
1728
+ ))
1729
+ )
1730
+
1672
1731
lazy val library : MultiScalaProject = MultiScalaProject (
1673
1732
id = " library" , base = file(" library" )
1674
1733
).enablePlugins(
1675
1734
MyScalaJSPlugin
1676
1735
).dependsOn(
1736
+ // Project dependencies
1677
1737
javalibintf % Provided , javalib,
1738
+ ).dependsOn(
1739
+ // MultiScalaProject dependencies
1740
+ scalalib,
1678
1741
).settings(
1679
1742
commonSettings,
1680
1743
publishSettings(Some (VersionScheme .BreakOnMajor )),
@@ -1727,25 +1790,6 @@ object Build {
1727
1790
*/
1728
1791
dependencyClasspath in doc ++= exportedProducts.value,
1729
1792
))
1730
- ).zippedSettings(Seq (" scalalib" , " libraryAux" ))(localProjects =>
1731
- inConfig(Compile )(Seq (
1732
- /* Add the .sjsir files from other lib projects
1733
- * (but not .class files)
1734
- */
1735
- mappings in packageBin := {
1736
- val libraryMappings = (mappings in packageBin).value
1737
-
1738
- val filter = (" *.sjsir" : NameFilter )
1739
-
1740
- val otherProducts = (
1741
- (products in localProjects(0 )).value ++
1742
- (products in localProjects(1 )).value)
1743
- val otherMappings =
1744
- otherProducts.flatMap(base => Path .selectSubpaths(base, filter))
1745
-
1746
- libraryMappings ++ otherMappings
1747
- },
1748
- ))
1749
1793
).withScalaJSCompiler
1750
1794
1751
1795
// The Scala.js version of sbt-testing-interface
0 commit comments