What is the idiomatic way for the SBT project to publish 2 artifacts?

I have a project that uses SBT as a build system and integrates Scala / Java and native sources with JNI.

To remain as flexible as possible, my current plan for publishing such a project is to publish two different jars: one containing a clean bytecode (linking the native binary to the end user) and one thick jar that also contains its own libraries and extracts them automatically.

To create a fat jar, I created a task called packageFat , which essentially copies the packageBin task with additional mappings into its own libraries and the -fat suffix added to the name.

The corresponding part of the assembly configuration can be viewed here: https://github.com/jodersky/flow/blob/master/project/nativefat.scala

However, with this configuration, any project that depends on mine and wants to include a fat jar should declare a dependency in this form:

libraryDependencies += "<organization>" %% "<name>" % "<version>" artifacts Artifact("<name>-fat", "jar", "jar")

I know that distributing projects using JNI is pretty awkward, but the part after the last “%” makes the dependency really cumbersome. So my question is: what is the idiomatic way in SBT to publish one regular jar and one live jar from one project?

+7
scala jni sbt
source share
1 answer

I would create a multi project build file with a base subproject that will be published "simple" and a bold subproject that will publish with JNI, and then you can use two different artifact names, for example foo-core and foo-fat .

In fact, foo-fat may depend on foo-core , and its own artifact will consist only of JNI material.

+4
source share

All Articles