These are chat archives for sbt/sbt-native-packager

16th
Oct 2015
Mike Mazur
@mikem
Oct 16 2015 05:48
Hi, I’m looking to package my project in a Docker container. What’s the difference between using sbt-native-packager and sbt-docker (https://github.com/marcuslonnberg/sbt-docker)?
Nepomuk Seiler
@muuki88
Oct 16 2015 06:33
sbt-docker is more of a low-level plugin. You have to configure mostly everything yourself, but you get a richer API for that. sbt-native-packager provides you with archetypes that let you start very fast, e.g. enablePlugins(JavaAppPackaging) and you get a working docker container with docker:packageBin. For customization we have only the very-low API and the most important settings via settings. Of course I'm a bit biased here ;)
Srepfler Srdan
@schrepfler
Oct 16 2015 09:01
in my list of library dependencies I have a zip artifact which is being filtered and not copied in the target universal lib directory
what's the correct way to map it?
Srepfler Srdan
@schrepfler
Oct 16 2015 09:15
I guess it will be something like
mappings in Universal := Seq(
  file("").getCanonicalFile() -> "lib/file.zip"
)
but if that file is a dependency and it's in the ivy repo, how do I get it's file reference?
Srepfler Srdan
@schrepfler
Oct 16 2015 09:29
actually, I just guess it's in the ivy repo, I fetch it via the libraryDependencies sequence
"com.comodo.lib" % "lib-zip" % versions.libZip artifacts(Artifact("lib-zip", "type", "zip")), ...
so perhaps there's an alternative rather than fetching it as a libraryDependency to fetch it to a particular location in the project...
Mike Mazur
@mikem
Oct 16 2015 10:53
@muuki88 great, thanks! That was very helpful. :+1:
Srepfler Srdan
@schrepfler
Oct 16 2015 21:20
featured sbt-native-packager as part of our "lessons learned" from investigating the microservice architectural style
I honestly felt as enabled by this plugin as much by the framework itself
Nepomuk Seiler
@muuki88
Oct 16 2015 21:24
@schrepfler your first snippet is bit risky as you override the complete mappings. Referencing files in your project can be done with
mappings in Universal += {
  val zipFile = baseDirectory.value / "path" / "to" / "file.zip"
  zipFile -> "lib/file.zip"
}
thanks for sharing the slides :)
Srepfler Srdan
@schrepfler
Oct 16 2015 21:26
no problem
my issue is that I don't have the file in the project
it's just a referenced libraryDependency
probably goes to the ivy repo of my profile
I guess it's filtered out of the /libs dir because it's not a *.jar?
Nepomuk Seiler
@muuki88
Oct 16 2015 21:40
yes, I think we fix that... I'll lookup the issue/pr
sbt/sbt-native-packager#102
sbt/sbt-native-packager#347
Srepfler Srdan
@schrepfler
Oct 16 2015 21:43
looks pretty similar although I would have thought a model jar being a classifier would have gone into libs anyway
we strictly filter for jars. This an "ancient" part of sbt-native-packager and hasn't been touched yet
Srepfler Srdan
@schrepfler
Oct 16 2015 21:44
can I expand the filter to allow other patterns as well somehow?
Nepomuk Seiler
@muuki88
Oct 16 2015 21:48
what do you mean by patterns? The fromClasspath helps you to get stuff that you defined in the libraryDependencies, but aren't jar files
mappings in Universal ++= fromClasspath((managedClasspath in Test).value, target = "test")
Srepfler Srdan
@schrepfler
Oct 16 2015 21:56
so that added all files from the test classpath and added it to the test directory?
Nepomuk Seiler
@muuki88
Oct 16 2015 21:56
exactly
see the scaladoc link above
all methods are explained there with examples
Srepfler Srdan
@schrepfler
Oct 16 2015 21:58
so perhaps I can do (managedClasspath in Compile).value ... filter that to match only on the pattern I want and set target = libs
Nepomuk Seiler
@muuki88
Oct 16 2015 21:58
yep
Srepfler Srdan
@schrepfler
Oct 16 2015 21:59
thanks
Srepfler Srdan
@schrepfler
Oct 16 2015 22:05
hm
I don't have fromClasspath on MappingsHelper O_o
sbt-native-packager 1.0.4
latest stable
Srepfler Srdan
@schrepfler
Oct 16 2015 22:18
ah, but this came in only from 1.0.5.M3
ok, makes sense then
Srepfler Srdan
@schrepfler
Oct 16 2015 22:24
@muuki88 it seems that is tagged but not published
Srepfler Srdan
@schrepfler
Oct 16 2015 23:08
hm, not published to github, but it's present on bintray