I have a multi-project build with a particularly messy module which contain several mainClasses. I would like to create several distribution packages for this messy module, each distribution package employing distinct file sets and employing different formats. Ideas?
相关问题
- Unusual use of the new keyword
- Get Runtime Type picked by implicit evidence
- What's the point of nonfinal singleton objects
- PlayFramework: how to transform each element of a
- Error in Scala Compiler: java.lang.AssertionError:
相关文章
- Gatling拓展插件开发,check(bodyString.saveAs("key"))怎么实现
- RDF libraries for Scala [closed]
- Why is my Dispatching on Actors scaled down in Akk
- How do you run cucumber with Scala 2.11 and sbt 0.
- GRPC: make high-throughput client in Java/Scala
- Setting up multiple test folders in a SBT project
- Testing request with CSRF Token in Play framework
- Run project with java options via sbt
This is the answer from the sbt-nativer-packager issue tracker where the same question was posted.
I'm adding this from the gitter chat as well:
I'm just arriving in this chat room and my knowledge of sbt-native-packager is virtually zero... but anyway... looks to me that
JavaAppPackaging
and other archetypes should actually be configurations extended from Universal. In this scenario, I would just create my own configuration extended fromJavaAppPackaging
and tweak the necessary bits according to my needs. And, finally, if the plugin just picksmappings in ThisScope
... it would pick my own scope, and notJavaAppPackaging
... and not Universal. So, let's go through this one by one.The sbt-native-packager plugin always pick mappings in Universal. This is not ideal. It should conceptually pick
mappings in ThisScope
SBT native packager provides two categories of AutoPlugins: FormatPlugins and ArchetypePlugins. FormatPlugins provide a new package format, e.g. UniversalPlugin (zip, tarball) or DebianPlugins (.deb). These plugins form a a hierarchy as they are build on top of each other:mappings, which define a
file -> targetpath
relation, are inherited with this patternSo for docker it looks like this
The linux format plugins use specialized mappings to preserve file permissions, but are basically the same.
Since
sbt-native-packager
plugin always pick mappings in Universal, I have to redefine mappings in Universal in each of my configurations Yes. If you want to define your own scope and inherit the mappings and change them you have to do this, like all other packaging plugins, too. I recommend putting this code into custom AutoPlugins in your project folder.For example (not tested, imports may be missing )
looks to me that JavaAppPackaging and other archetypes should actually be configurations extended from Universal JavaAppPackaging is an archetype, which means this plugin doesn't bring any new packaging formats, thus no new scopes. It configures all the packaging formats it can and enables them.
You package stuff by specifying the scope:
So if you need to customize your output format you are doing this in the respecting scope.
See: https://github.com/sbt/sbt-native-packager/issues/746
IMPORTANT: This is an "answer in progress". IT DOES NOT WORK YET!
This is an example of how one could achieve this.
The basic idea is that we add configurations for different packages to be generated. Each configuration tells which files will be present in the package. This does not work as expected. See my comments after the code.
Now observe configuration
BuilderRV
which in comments.It is basically the same thing as configuration
BuilderRS
, except that we are now deploying a different shell script in thebin
folder. There some other small differences, but not relevant to this argumentation. There are two problems:The
sbt-native-packager
plugin always pickmappings in Universal
. This is not ideal. It should conceptually pickmappings in ThisScope
.Since
sbt-native-packager
plugin always pickmappings in Universal
, I have to redefinemappings in Universal
in each of my configurations. And this is a problem becausemappings in Universal
is defined as a function of itself in all configurations: the result is that we ended up chaining logic tomapppings in Universal
each time we redefined it in each configuration. This causes trouble in this example in particular because the configurationBuilderRV
(the second one) will perform not only its filter, but also the filter defined inBuilderRS
(the first one), which is not what I want.