Open BillyAutrey opened 1 month ago
The following test fails under sbt 2.0.
https://github.com/sbt/sbt-web/blob/main/src/sbt-test/sbt-web/multi-module/build.sbt#L16
sbt 2 changes the default value for exportJars := true. This changes underlying logic to calculate exportable assets.
exportJars := true
The corresponding check for e.js at modules/c/target/web/public/main/js/e.js fails:
e.js
modules/c/target/web/public/main/js/e.js
[info] [error] (fileCheckC) java.lang.AssertionError: assertion failed: Could not find e.js
In SbtWeb.scala, importDirectly works by looking for internalWebModules. This call looks for mapping metadata with the key webModulesLib here. https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L464
importDirectly
internalWebModules
webModulesLib
In sbt 1, here's an example of the corresponding metadata in this same test:
(analysis: Analysis: , artifact: Artifact(e, jar, jar, None, Vector(compile), None, Map(), None, false), moduleID: e:e:0.1.0-SNAPSHOT, configuration: compile) (webModulesLib: e) (analysis: Analysis: , artifact: Artifact(x, jar, jar, None, Vector(compile), None, Map(), None, false), moduleID: x:x:0.1.0-SNAPSHOT, configuration: compile)
In sbt 2, the webModulesLib entry doesn't exist at all.
The code that sets this attribute is in exportProducts, which is called when exportedProducts is originally set.
exportProducts
exportedProducts
https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L434-L441
Compile / exportedProducts is added to via exportAssets https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L254
Compile / exportedProducts
exportAssets
https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L414-L432
Note that line 419 checks the state of exportJars. This changes the export of assets, which doesn't break most things. But in this case, if exportJars := false is set for module/c, this particular test passes. Others do not, however.
exportJars
exportJars := false
module/c
This is also blocking #255
I spoke to Eugene, and he suggested using Def.declareOutputDirectory to redefine where the file goes. https://eed3si9n.com/sudori-part4/
Def.declareOutputDirectory
Issue
The following test fails under sbt 2.0.
https://github.com/sbt/sbt-web/blob/main/src/sbt-test/sbt-web/multi-module/build.sbt#L16
Short version
sbt 2 changes the default value for
exportJars := true
. This changes underlying logic to calculate exportable assets.Deeper Explanation
The corresponding check for
e.js
atmodules/c/target/web/public/main/js/e.js
fails:In SbtWeb.scala,
importDirectly
works by looking forinternalWebModules
. This call looks for mapping metadata with the keywebModulesLib
here. https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L464In sbt 1, here's an example of the corresponding metadata in this same test:
In sbt 2, the
webModulesLib
entry doesn't exist at all.The code that sets this attribute is in
exportProducts
, which is called whenexportedProducts
is originally set.https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L434-L441
Compile / exportedProducts
is added to viaexportAssets
https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L254https://github.com/sbt/sbt-web/blob/b92d20e7db95474fd3af8d5c826994555572797a/src/main/scala/com/typesafe/sbt/web/SbtWeb.scala#L414-L432
Note that line 419 checks the state of
exportJars
. This changes the export of assets, which doesn't break most things. But in this case, ifexportJars := false
is set formodule/c
, this particular test passes. Others do not, however.