加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 使用sbt(第三方)发布jar文件

发布时间:2020-12-16 09:24:35 所属栏目:安全 来源:网络整理
导读:您好我有5个jar文件,并尝试使用sbt将它们发布到本地存储库. 但是当我将它们放在unmanagedBase目录(如lib /)时,它们不会被publishLocal复制.有没有简单的方法将它们包含在发布过程中? 目前maven在这里有类似的解决方案: http://maven.apache.org/guides/min
您好我有5个jar文件,并尝试使用sbt将它们发布到本地存储库.
但是当我将它们放在unmanagedBase目录(如lib /)时,它们不会被publishLocal复制.有没有简单的方法将它们包含在发布过程中?

目前maven在这里有类似的解决方案:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

解决方法

一种选择是为要发布的每个jar定义子项目.你的主要项目取决于每个.为每个子项目提供适当的名称,版本和组织.对于每个子项目,将其jar放在不在类路径上的某个地方,并使packageBin的输出成为该jar.

例如(sbt 0.13 build.sbt),

lazy val main = project.dependsOn(subA)

lazy val subA = project.settings(
   name := "third-party",organization := "org.example",version := "1.4",packageBin in Compile := baseDirectory.value / "bin" / "third-party.jar",// if there aren't doc/src jars use the following to
   //   avoid publishing empty jars locally
   // otherwise,define packageDoc/packageSrc like packageBin 
   publishArtifact in packageDoc := false,publishArtifact in packageSrc := false,// tell sbt to put the jar on main's classpath
   //   and not the (empty) class directory
   exportJars := true,// set this to not add _<scalaBinaryVersion> to the name
   crossPaths := true
)

这种方法允许您更改subA / bin / third-party.jar中的jar并立即使用它,后续的publishLocal将在本地发布它.

如果您希望在本地单独发布它,以便它不是项目的一部分,请将subA定义为独立项目.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读