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

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

To stay as flexible as possible, my current plan to publish this kind of project is to publish two different jars: one containing pure bytecode (the referencing of the native binary is left up to the end-user) and one fat jar that also contains the native libraries and extracts them automatically.

To generate a fat jar, I created a task called packageFat that essentially copies the task packageBin with additional mappings to the native libraries and the suffix '-fat' appended to the name.

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

However, with this kind of configuration, any project that depends on mine and wishes to include the fat jar has to declare a dependency in this form:

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

I know that distributing projects using JNI is kind of clumsy, 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 normal jar and one fat jar from one project?


I would create a multi project build file, with a core sub project that will be published "plain", and a fat sub project which will publish with JNI, and then you could use two different artifact names, like foo-core and foo-fat .

In fact, foo-fat could depend on foo-core , and its own artifact would only consist of the JNI stuff.

链接地址: http://www.djcxy.com/p/76958.html

上一篇: Angular $ sce vs外部区域设置文件中的HTML

下一篇: SBT项目发布两件神器的惯用​​方式是什么?