如何使用 sbt-native-packager 创建基本项目设置 [英] How to create a basic project setup using sbt-native-packager

查看:45
本文介绍了如何使用 sbt-native-packager 创建基本项目设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 SBT 的项目设置,可以创建子项目工件.

I have a project setup working with SBT to the point of creating sub-project artifacts.

我一直在寻找一种方法来创建包含子项目 JAR 文件和一些元信息的 JAR 文件.根据建议,我查看了 sbt-native-packager,它似乎具有我需要的功能.

I have been searching for a way to create a JAR file that contains sub-project JAR files along with some meta information. Based on suggestions, I looked at sbt-native-packager and it seems to have the capabilities I need.

我想知道是否有人愿意通过提供有关为插件创建框架包规范的提示来帮助我走这条路.

I am wondering if someone would be willing to help me along this path by providing tips on creating a skeleton package specification for the plugin.

我觉得我的配置很简单.

I think my configuration is pretty simple.

我最终想要的是一个包含以下内容的 JAR 文件:

What I want to end up with is a JAR file with the following contents:

/manifest.xml
 module.xml
 modules/sub-project-one.jar
         sub-project-two.jar
         sub-project-three.jar

manifest.xml 和 module.xml 文件都将根据项目信息生成.生成的 JAR 文件的名称将基于根项目的名称、版本和后缀nkp.jar"(例如 overlay-1.0.1.nkp.jar).

Both the manifest.xml and module.xml files will be generated from project information. The name of the resulting JAR file will be based on the name of the root project, it's version and a suffix "nkp.jar" (e.g. overlay-1.0.1.nkp.jar).

在此先感谢您为我提供的帮助.

Thanks in advance for any help getting me going with this.

-- 兰迪

推荐答案

以下是您想要的基础知识:

Here's the basics of what you want:

val createManifestXml = taskKey[File]("Creates the packaged maniest.xml")

val createModuleXml = taskKey[File]("Creates the module.xml file.")

// TODO - Define createManifestXml + createModuleXml

mappings in Universal ++= {
   Map(createManifestXml.value -> "manifest.xml"
      module.xml -> "module.xml")
}

mappings in Universal ++= {
   val moduleJars = 
      Seq((packageBin in subProjectOne).value, 
          (packageBin in subProjectTwo).value,
          (packageBin in subProjectThree).value)
   moduleJars map { jar =>
     jar -> s"module/${jar.getName}"
   }
}

这将确保可以生成 tgz/txz/zip.然后,您可以使用通用"通用 -> msi 和通用 -> rpm/deb 映射,也可以根据需要手动创建该映射.

This will insure that the tgz/txz/zip can be generated. You can then either use the "generic" universal -> msi and universal -> rpm/deb mappings or create that mapping by hand if you desire.

希望有帮助!

这篇关于如何使用 sbt-native-packager 创建基本项目设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆