How to disable package and publish tasks for root aggregate module in multi-module build?

paradigmatic picture paradigmatic · Jan 9, 2012 · Viewed 10.5k times · Source

I have a multiproject SBT project, which looks like the example on SBT doc:

import sbt._
import Keys._

object HelloBuild extends Build {
  lazy val root = Project(id = "hello",
                        base = file(".")) aggregate(foo, bar)

  lazy val foo = Project(id = "hello-foo",
                       base = file("foo"))

  lazy val bar = Project(id = "hello-bar",
                       base = file("bar"))
}

Because root is just a virtual project to aggregate both subprojects, I would like to avoid package generation (and artifact publication), but still generate package (and publish) for both subprojects.

Is there an easy way to achieve it ?

Answer

Rich Dougherty picture Rich Dougherty · Aug 30, 2013

Instead of playing whac-a-mole by listing specific tasks to disable (publish, publish-local, publish-signed, etc), another option is to turn off artifact publishing at the source.

publishArtifact := false

Even though there's no publishing happening, I also found I needed to supply a publishTo value to make sbt-pgp's publish-signed task happy. It needs this value, even if it never uses it.

publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))