mitchus
mitchus

Reputation: 4877

sbt: avoiding multiple assembly / publish steps in java subproject

I have an sbt (0.13.8) project with several subprojects, most of them in pure Scala. They are cross assemblyed and published;

crossScalaVersions := Seq("2.10.6", "2.11.8")
releaseCrossBuild := true

This works quite nicely so far.

Now I am adding a Java subproject, which depends on some of the Scala subprojects. However, I can't find a way to avoid it assemblying and publishing multiple times. While the following

crossPaths := false

has the effect that at the end I have only one jar in the java subproject, when I run

sbt +assembly

I still see it being done for all Scala versions. This I could live with, but

sbt +assembly +publish

tries to publish the same (java subproject) artifact multiple times.

Is there a way, ideally without yet another plugin, to avoid this issue?

Upvotes: 1

Views: 196

Answers (1)

thirstycrow
thirstycrow

Reputation: 2824

build.sbt:

scalaVersion := "2.11.7"

crossScalaVersions := Seq("2.10.5", "2.11.7")

lazy val scalaOnly = project
  .in(file("."))
  .aggregate(scalaPrj)
  .settings(
    packagedArtifacts := Map.empty
  )

lazy val scalaPrj = project
  .in(file("scala-prj"))

lazy val javaPrj = project
  .in(file("java-prj"))
  .dependsOn(scalaPrj)

lazy val javaOnly = project
  .in(file("java-dummy-aggregator"))
  .aggregate(javaPrj)
  .settings(
    crossScalaVersions := Seq("2.11.7"),
    packagedArtifacts := Map.empty
  )

Switch to javaOnly before publishing:

;project javaOnly ;+publish

Upvotes: 1

Related Questions