sbt-site
sbt-site copied to clipboard
Preview task is launched for each aggregated submodule
Since the introduction of sbt-site as a collection of auto plugins, the previewSite task is launched by each submodule, if the sbt project follow this pattern:
- An auto plugin, let's say
SphinxPlugin, is enabled on the root project, which has some aggregated submodules - Running
sbt previewSitewill result in each module trying to run the task
However, only the parent project will actually run makeSite. If one of the submodule manages to open jetty before the parent project can make the site, the opened url will be empty:
This behavior does not happen on 0.8.2, where the settings are set directly on the root project and no inheritance seems to occur.
I'm not sure how I could enable the SphinxPlugin without getting what the doc says:
Aggregation means that running a task on the aggregate project will also run it on the aggregated projects.
Thanks @notdryft. I'm not entirely sure how to address this, and need to ask around the SBT community for tips.
One possibility would be to remove the preview site plugin and make the preview tasks live in the generator plugins, so project.enablePlugin(SphinxPlugin) would also add the previewSite site to that project.
Hi guys, is there any workaround for this? I was trying to fix it by setting aggregate in for various combinations of scopes but none of them works. Also I was not able to use sbt-site on subproject(NPE is thrown).
Maybe I can downgrade to some older version that works? It is rather critical for multi-module builds
Edit:
I have found the workaround: makeSite := { (makeSite in subproject).value } on root project allowed me to use subproject/previewAuto
@Krever Given the age of this issue I think it's safe to say there's no ready solutions. Sure would welcome a PR if you're able to find a solution! :-)
I suspect part (all?) of this problem is because com.typesafe.sbt.site.Preview#runTask is not scoping the task to the project on which previewAuto is run on which means it will run makeSite on the root project.
It's a bit hard to tell because it is a hacky dynamic task evaluation but if you run sbt -Dsbt.task.timings=true then you can see which tasks actually run:
sbt:root> docs/previewAuto
[info] Total time: 3 ms
[info] root / makeSite: 1 ms
[info] Total time: 0 ms
[info] root / makeSite: 1 ms
[info] Total time: 4 ms
[info] docs / previewAuto: 9 ms
[info] root / makeSite : 1 ms