sbt-site icon indicating copy to clipboard operation
sbt-site copied to clipboard

Preview task is launched for each aggregated submodule

Open notdryft opened this issue 9 years ago • 5 comments

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 previewSite will 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:

screen shot 2016-06-03 at 17 31 44

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. 

notdryft avatar Jun 03 '16 15:06 notdryft

Thanks @notdryft. I'm not entirely sure how to address this, and need to ask around the SBT community for tips.

metasim avatar Jun 04 '16 15:06 metasim

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.

jonas avatar Sep 02 '16 13:09 jonas

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 avatar Jun 17 '17 08:06 Krever

@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! :-)

metasim avatar Jun 19 '17 12:06 metasim

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

steinybot avatar Jul 10 '22 00:07 steinybot