Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT: How to publish both the aggregate project and all modules on Sonatype?

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?

like image 537
Eric Avatar asked Oct 03 '22 14:10

Eric


2 Answers

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.

like image 50
Eugene Yokota Avatar answered Oct 05 '22 04:10

Eugene Yokota


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

like image 35
Ross Avatar answered Oct 05 '22 02:10

Ross