SBT 0.7 .X:
据我所知,没有默认的实现。但是,您可以使用SBT的文件实用程序。
尝试使用下面的示例,将工件jar复制到tmp目录中,压缩目录并删除它。应该直接将其扩展到依赖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
}
}
以下函数来自
FileUtilities
以上使用:
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]
他们的声明应该不言自明。