Reputation: 11244
I have a multi project build where I define an application, an api library an implementation of that api library.
The API library should be published. The application (together with it's dependencies) should be packaged, using the universal packager plugin.
lazy val app = project.in(file("."))
.enablePlugins(PlayScala)
.dependsOn(api, impl, client % "test->test")
.aggregate(api, impl, client)
.settings(commonSettings:_*)
.settings(
publishArtifact := false
)
lazy val api =
project.in(file("modules/api"))
.settings(name := "app-api")
lazy val client = project.in(file("modules/client"))
.dependsOn(api)
.settings(name := "app-client")
lazy val impl = project.in(file("modules/impl"))
.dependsOn(api)
.settings(name := "app-impl")
.settings(
publishArtifact := false
)
The publishArtifact := false
prevents creation of the jar artifact app-impl
. The consequence of this is that it's not included in the dist
and stage
results.
Is there way (other than setting publish := ()
) to configure the project in such a way that it will produce an artifact but not publish it?
Upvotes: 4
Views: 215
Reputation: 6102
Here is the reason why disabling publishArtifact
in a project will disable triggering the creation of the jar: for some reason all the pkgTasks
(which lead to packagedArtifacts
) are made dependant on the value of publishArtifact
.
I don't know the exact reason this is the case, but I think an assumption was made that it would be a waste to package when you don't want to publish. Obviously what the universal packager does to bundle all the artefacts is getting tripped up, and I'm not sure if the fix is in the plugin or in sbt.
Either way, I would recommend using publish := ()
, as one alternative I've found is much more verbose:
publishLocalConfiguration :=
Classpaths.publishConfig(artifacts = Map(), ivyFile = None, checksums = Nil),
publishConfiguration :=
Classpaths.publishConfig(artifacts = Map(), ivyFile = None, checksums = Nil)
Upvotes: 1