5

I have a SBT project which I was publishing to Sonatype with no issue and I converted it to a multi-module SBT project. Now I want to:

  • publish the jar/javadoc/sources/pom file containing all the aggregated submodules to Sonatype (meaning that they should be signed with the sbt-pgp plugin)

  • publish each individual submodule to Sonatype as well

I tried to use the sbt assembly plugin for this but didn't manage to get very far. Do you have a sample Build.scala file which would show what is the best structure to accomplish this?

Eric
  • 15,494
  • 38
  • 61
  • Is this project in question available on github if I want to test my theory? – Eugene Yokota Oct 28 '13 at 01:01
  • Do you mean like we do in lift? We have the framework aggregate project which I do publish and sends everything, and you can also go into individual sub projects – fmpwizard Oct 28 '13 at 02:35
  • @EugeneYokota: yes it is for specs2: https://github.com/etorreborre/specs2/tree/specs2-modules. But I don't want to give you work that I should be doing myself. – Eric Oct 28 '13 at 03:18
  • @fmpwizard yes if you publish the sub projects as well. I'll have a look at lift's own configuration, thanks. – Eric Oct 28 '13 at 03:18
  • Then yes, there isn't really a framework jar, it is only the aggregate. And then subprojects like lift-json , lift-util end up on sonatype, with their own docs, source, etc – fmpwizard Oct 28 '13 at 03:33
  • @Eric It wasn't too much work, plus I owe specs2 man-months anyways. The meta question – Why do you need to publish an aggregate jar instead of keeping it broken down? – Eugene Yokota Oct 28 '13 at 04:48
  • I want to ease the transition for people having the "big" dependency. When they are ready they can change for smaller jars. – Eric Oct 28 '13 at 10:25

2 Answers2

3

I don't know if it's possible with currently available plugins, but using ScopeFilter, you might be able to create an artificial project that aggregates all sources, from there it's just the matter of calling publishSigned in there.

See how I aggregate source in sbt-unidoc.

Here's the proof of concept: https://github.com/eed3si9n/specs2/commit/18f6405c91cf995f621a84c65e05d66407ba4964

With the change I was able to run package, doc etc. You might have to aggregate *.class if you use macros.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
1

I use the sbt assembly plugin for Casbah - https://github.com/mongodb/casbah

Casbah has a top level aggregate project but I also package a single all dependencies jar by adding an extra artifact to the build:

addArtifact(Artifact("casbah-alldep", "pom", "jar"), assembly),

See the build file for more info: https://github.com/mongodb/casbah/blob/master/project/CasbahBuild.scala

Ross
  • 17,861
  • 2
  • 55
  • 73