How to create a basic project setup using sbt-native-packager

回眸只為那壹抹淺笑 提交于 2019-12-11 02:47:17

问题


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

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.

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

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.

-- Randy


回答1:


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}"
   }
}

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.

Hope that helps!



来源:https://stackoverflow.com/questions/18744844/how-to-create-a-basic-project-setup-using-sbt-native-packager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!