scala - How to ZIP files with a prefix folder in SBT -
scala - How to ZIP files with a prefix folder in SBT -
to generate distribution zip simple build tool 1 can do
def distpath = ( ((outputpath ##) / defaultjarname) +++ maindependencies.scalajars ) lazy val dist = ziptask(distpath, "dist", "distribution.zip") dependson (`package`) describedas("zips project.")
this adds jar files root of zip. how 1 add together jars lib
subfolder in zip?
for sbt 0.7.x:
nothing implemented default far know. however, can utilize sbt's fileutilities.
try playing around next example, copies artifact jar tmp dir, zips dir, , deletes it. should straightforward extend dependent libs.
class project(info: projectinfo) extends defaultproject(info) { def distpath = { ((outputpath ##) / defaultjarname) +++ maindependencies.scalajars } private def str2path(str: string): path = str lazy val dist = task { fileutilities.copyfile((outputpath ##) / defaultjarname, "tmp" / "lib" / defaultjarname, log) fileutilities.zip(list(str2path("tmp")), "dist.zip", true, log) fileutilities.clean("tmp", log) none } }
the next functions fileutilities
used above:
def zip(sources: iterable[path], outputzip: path, recursive: boolean, log: logger) def copyfile(sourcefile: path, targetfile: path, log: logger): option[string] def clean(file: path, log: logger): option[string]
their declarations should self-explanatory.
scala build sbt
Comments
Post a Comment