Ivy 额外属性可能需要 Ivy 存储库才能工作,如果您使用 Artifactory,这应该可以工作。 sbt 确实在内部使用额外的属性来编码 Maven 存储库上的 Scala 版本,但我不知道这些位是否公开。
这是我用作测试的内容。
构建.sbt
lazy val root = (project in file(".")).
settings(
bintrayReleaseOnPublish in ThisBuild := false
)
val customPattern = "[organisation]/[module]/" +
"(scala_[scalaVersion]/)(sbt_[sbtVersion]/)(branch_[branch_name]/)" +
"[revision]/[type]s/[artifact](-[classifier]).[ext]"
lazy val libExtra = (project in file("libExtra")).
settings(
version := "0.1",
scalaVersion := "2.11.7",
organization := "com.example",
name := "somelibrary",
projectID := {
val previous = projectID.value
previous.extra("branch_name" -> "master-api-model-separation")
},
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
bintrayVcsUrl := Some("[email protected] /cdn-cgi/l/email-protection:you/your-repo.git"),
bintrayOrganization := None,
bintrayRepository := "test-test-test",
publishMavenStyle := false,
checksums in publish := Nil,
publishTo := {
Some(URLRepository("test-bintray-ivy", Patterns(
s"https://api.bintray.com/content/you/${bintrayRepository.value}/" +
customPattern +
s";bt_package={normalizedName.value};bt_version={version.value}")))
}
)
lazy val app = (project in file("app")).
settings(
scalaVersion := "2.11.7",
organization := "foo",
libraryDependencies += "com.example" %% "somelibrary" % "0.1" extra("branch_name" -> "master-api-model-separation"),
resolvers += Resolver.url("test-bintray-ivy", url("https://dl.bintray.com/you/test-test-test/"))(Patterns(
customPattern)),
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)
项目/build.properties
sbt.version=0.13.8
项目/bintray.sbt
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
libExtra/src/main/scala/Something
object Something
一半的设置基本上设置为发布到虚拟 Bintray 存储库以进行测试。以下是一些注意事项:
- 名字
branch
已被占用,所以我认为您无法使用它。我是苏金branch_name
.
- publishTo 包含一个自定义工件模式,其中包含嵌入在 URL 中的额外属性。
Using app
我能够从 Bintray 解析 JAR:
app> compile
[info] Updating {file:/Users/xxx/extra-attribute-test/}app...
[info] Resolving jline#jline;2.12.1 ...
[info] downloading https://dl.bintray.com/eed3si9n/test-test-test/com/example/somelibrary_2.11/branch_master-api-model-separation/0.1/jars/somelibrary_2.11.jar ...
未来的改进:这是我尝试使用 Maven 存储库来做到这一点的尝试 -https://gist.github.com/eed3si9n/a6de413b1ced84649ae0 https://gist.github.com/eed3si9n/a6de413b1ced84649ae0