I use universal sbt-native-packager to generate a zip file distribution.
sbt universal:packageBin
The generated zip file, once extracted, contains everything inside a main directory named as my zip file:
unzip my-project-0.0.1.zip
my-project-0.0.1/bin
my-project-0.0.1/lib
my-project-0.0.1/conf
...
How can I create a zip that has no root folder, so that when extracted it will have a structure like that?
bin
lib
conf
Thanks
I'm not confident enough with sbt and scala to submit a pull request. bash scripting has to be excluded right now, so my current (and ugly) solution is this one:
packageBin in Universal := { val originalFileName = (packageBin in Universal).value val (base, ext) = originalFileName.baseAndExt val newFileName = file(originalFileName.getParent) / (base + "_dist." + ext) val extractedFiles = IO.unzip(originalFileName,file(originalFileName.getParent)) val mappings: Set[(File, String)] = extractedFiles.map( f => (f, f.getAbsolutePath.substring(originalFileName.getParent.size + base.size + 2))) val binFiles = mappings.filter{ case (file, path) => path.startsWith("bin/")} for (f <- binFiles) f._1.setExecutable(true) ZipHelper.zip(mappings,newFileName) IO.move(newFileName, originalFileName) IO.delete(file(originalFileName.getParent + "/" + originalFileName.base)) originalFileName }
The solution proposed on github seems to be way nicer than mine even tough it doesn't work for me: https://github.com/sbt/sbt-native-packager/issues/276