Re: [sbt] Publish all project dependencies

428 views
Skip to first unread message

Mark Harrah

unread,
Aug 30, 2012, 6:17:58 AM8/30/12
to simple-b...@googlegroups.com
On Tue, 28 Aug 2012 10:13:19 -0700 (PDT)
Roman Timushev <rti...@gmail.com> wrote:

> Hi everyone,
>
> I am going to write a small command-line application and want to start it
> with a single command from the sbt console. After some investigation I
> found out that there is a conscript-plugin is doing almost what I need. The
> only thing that doesn't work is that conscript-plugin publishes only one
> project, but the dependencies remain unpublished and resolution fails.
>
> Is there any way to run "publish-local" task for all project dependencies
> without need to specify them explicitly? I'm even ok with publishing
> everything, so I tried to add a dependency to (publishLocal in
> LocalRootProject) but even with (aggregate in publishLocal := true) it
> doesn't work.

Aggregation[1] is the right approach if you are running 'publish-local' from the command line. In particular, use something like:

lazy val root = Project(id = "hello",
base = file(".")) aggregate(foo, bar)

The 'aggregate' setting is intended to restrict this further, not enable it. For example, if you don't want 'clean' to be aggregated, you would use 'aggregate in clean := false'.

Aggregation only kicks in for the top-level task being run, however. If you are not running 'publish-local' directly, you would need to make it depend on the publish-local tasks in other projects explicitly.

-Mark

[1] https://github.com/harrah/xsbt/wiki/Getting-Started-Multi-Project

> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/aO3QFuEYVosJ.
> To post to this group, send email to simple-b...@googlegroups.com.
> To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
>

Mark Harrah

unread,
Sep 1, 2012, 9:51:31 AM9/1/12
to simple-b...@googlegroups.com
On Thu, 30 Aug 2012 03:38:15 -0700 (PDT)
Roman Timushev <rti...@gmail.com> wrote:

> Hi Mark,
>
> Thank you for your answer. We have a properly configured aggregation
> hierarchy and when I call "publish-local" manually it publishes everything.
> As you already explained, the problem I have is that I run this task as a
> dependency and therefore an aggregation is not taken into account.
>
> Currently I've solved the issue by adding dependencies to all
> "publish-local" tasks I need, but it is a bit verbose.

Yes, explicit dependencies is perhaps the simplest, if repetitive, approach for now.

> Anyway, I think that it is possible to avoid such hard-coding, just my
> sbt-fu is not strong enough — sbt is able to run "compile" for
> dependencies, so there probably is a way to run "publish-local" for
> dependencies. May be I'll have some time to dive deeper into sbt sources
> next week, the answer must be there :-)

Right, sbt can do it and there is a way, but it hasn't been made very accessible. I doubt it would make your build more readable or maintainable as it is currently.

There are a couple of examples in sbt's default settings here:

http://harrah.github.com/xsbt/latest/sxr/Defaults.scala.html#330509

Pick the task ('publishLocal', for example), a default if the project doesn't contain the task, whether to include aggregate dependencies, and whether to include the task in the current project. Then, run all of them. Again, I don't claim this is easy now or that it is intrinsically complicated, just that there isn't a clean API for it right now.

-Mark

> --
> Roman
> > > To post to this group, send email to simple-b...@googlegroups.com<javascript:>.
> >
> > > To unsubscribe from this group, send email to
> > simple-build-t...@googlegroups.com <javascript:>.
> > > For more options, visit this group at
> > http://groups.google.com/group/simple-build-tool?hl=en.
> > >
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/wEvxoICL6DcJ.
Reply all
Reply to author
Forward
0 new messages