5

I have a multi-project build that makes extensive use of sub-projects in order to make dependencies between them explicit (by means of dependsOn - the sub-projects act as layers).

If it comes to publishing I want to roll up all the sub-project artifacts into the artifact of the main project (jar), and collect all their libraryDependencies. In other words, I want to publish as if there would be no sub-projects, just a single root project containing all my code (i.e. no ueber-jar). The sub-projects are only there to break up the compilation into smaller scopes with enforced dependency structure, they are not supposed to be distributed separately.

What is the best way to achieve that?

  • 1
    If you really want to do this (although I do not see the problem of publishing multiple jars, as sbt or maven will handle the transitive dependencies for you), I would first try by modifying the main project package content using: http://www.scala-sbt.org/0.13/docs/Howto-Package.html#Modify+the+contents+of+the+package, or use sbt-assembly, where you can exclude dependencies (so, exclude everything except your own packages) – Olivier Samyn May 22 '16 at 21:39
  • the sub-projects are always delivered together, I don't want them as units of distribution, just as units of compilation. I have edited my question to clarify this – Peter Mehlitz May 23 '16 at 17:03
  • did u find a soln to this? – Tony Z Apr 26 '17 at 06:00
  • not really - I ended up distributing the sub-project jars separately (see https://github.com/NASARace/race) as sort of a lemons -> lemonade approach. It turned out I had to refactor and then use the subs to minimize 3rd party dependencies in code that imports my jars, i.e. the original assumption that all sub-jars would always be imported together by users of my system did not hold anymore. However, that is a project specific solution and I still see a need to solve the general problem - artifact distribution (jars) and sub-project partitioning are not necessarily the same. – Peter Mehlitz Apr 27 '17 at 16:30

0 Answers0