从SBT发布一个自定义工件到JFrog



我尝试从SBT发布一个自定义工件到JFrog工件。我有以下项目:SBT版本1.4.3

项目/plugins.sbt:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")

构建。

ThisBuild / scalaVersion := "2.11.12"
ThisBuild / organization := "my.org"
ThisBuild / organizationName := "company"
lazy val root = (project in file(".")).settings(
name := "my-project"
)
publishTo := {
val artifactory = "https://artifactory.company.org/artifactory/repo"
if (isSnapshot.value)
Some(
"Artifactory Realm" at s"$artifactory-snapshots;build.timestamp=" + new java.util.Date().getTime
)
else
Some("Artifactory Realm" at s"$artifactory-releases;keep_forever=release-artifact")
}
artifact in (Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
art.withClassifier(Some("assembly"))
}
addArtifact(artifact in (Compile, assembly), assembly)
val packAnsible = taskKey[File]("Pack ansible files.")
val ansibleArtifactName = settingKey[String]("Ansible artifact name")
packAnsible := {
val ansibleZip =
target.value / s"scala-${scalaBinaryVersion.value}" / s"${name.value}.zip"
IO.zip(
IO.listFiles(Path("ansible").asFile).map(f => (f, f.name)),
ansibleZip,
None
)
ansibleZip
}
artifact in packAnsible := Artifact(name.value, "zip", "zip").withClassifier(Some("ansible"))
addArtifact(artifact in packAnsible, packAnsible)

你可以看到我添加了2个工件要发布:

  1. uber jar with classifier "assembly">
  2. 一个带有分类器"ansible"的zip文件

在我的存储库中发布后,我可以找到几乎所有我想要的:

  • 回购/com/org/my - project_2.11/0.1.0 snapshot/my - project_2.11 0.1.0 0.3.2 - 20210301.161254 - 1 - assembly.jar
  • 回购/com/org/my - project_2.11/0.1.0 snapshot/my - project_2.11 0.1.0 0.3.2 - 20210301.161254 - 1 - javadoc.jar
  • 回购/com/org/my - project_2.11/0.1.0 snapshot/my - project_2.11 0.1.0 0.3.2 - 20210301.161254 - 1 - sources.jar
  • 回购/com/org/my - project_2.11/0.1.0 snapshot/my - project_2.11 0.1.0 0.3.2 - 20210301.161254 - 1. - jar
  • 回购/com/org/my - project_2.11/0.1.0 snapshot/my - project_2.11 0.1.0 0.3.2 - 20210301.161254 - 1. - pom
  • 回购/com/org/my-project_2.11/0.1.0-SNAPSHOT/my-project_2.11-0.1.0-0.3.2-SNAPSHOT-ansible.zip
  • 回购/com/org/my-project_2.11/0.1.0-SNAPSHOT/maven-metadata.xml

我可以在maven-metadata中看到所有其他工件,除了我的zip和jar的名称不包含构建。因此,在下次构建时将失败,除非我赋予用户覆盖/删除的权利,而我不希望这样做。

我试着遵循文档并在/usr/local/etc/sbtopts的构建服务器和我的项目的根目录中添加了-Dsbt.override.build.repos=true

我希望所有的神器(目前只有我的服装没有)都能被适当地出版。

显然,问题出在我为自定义工件使用的名称上:

artifact in packAnsible := Artifact(name.value, "zip", "zip").withClassifier(Some("ansible"))

应:

artifact in packAnsible := Artifact((Compile / packageBin / artifact).value.name, "zip", "zip")
.withClassifier(Some("ansible"))

在实际构建中,我有不同的.-

最新更新