SBT 1.3.x:如何设置自定义artifactPattern



我有以下任务将ivy格式的自定义工件(在本例中为gz文件(发布到远程工件工厂。


val publishImageTask = publishImageKey := {
println("Publishing gz file ...")
val extracted = Project.extract(state.value)
Project.runTask(publish, extracted.append(List(
publishTo := Some("MyArtifactory" at "https://xxx/artifactory/"),
publishMavenStyle := false,
isSnapshot := true,
publishArtifact in Compile := false,
publishArtifact in Test := false,
organization := "com.example.my",
moduleName := "myproject",
crossPaths := false,
credentials += Credentials(credentialsFile),
description := "A gz file",
version := "1.0.0",
packagedArtifacts in publish := {
val gzFile =  new File("/tmp/foo.tar.gz")
println(s"gzFile:$gzFile")
val artifact = Artifact(name="foo",  `type` = "release", extension = "tar.gz")
Map(artifact -> gzFile)
}
), state.value), true)
}

上述任务将尝试发布到

https://xxx/artifactory/com/example/my/myproject/1.0.0/foo-1.0.0.tar.gz

上面似乎使用了artifactPattern

[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]

在sbt中,如何设置自定义artifactPattern

[organization]/[module]/[revision]/[type]s/[artifact](-[classifier])-[revision].[ext]

使得URL包括类型";释放";

https://xxx/artifactory/com/example/my/myproject/1.0.0/releases/foo.tar-1.0.0.gz
Thanks in advance for any assistance ! 
Shing

原来artifactPattern可以在URLDepository中指定,它扩展了Resolver。In而不是

publishTo := Some("MyArtifactory" at "https://xxx/artifactory/"),

使用

val repoUrl = "https://xxx/artifactory/"

val resolver = URLRepository(
name = "DockerImageRepo",
patterns = Patterns(
ivyPatterns =Vector(s"${repoUrl}/[organization]/[module]/[revision]/[type]s/ivy-[revision].xml"),    
artifactPatterns = Vector(s"${repoUrl}/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier])-[revision].[ext]"),
isMavenCompatible = true,
descriptorOptional = false,
skipConsistencyCheck = true
)
)
publishTo := Option(resolver)

相关内容

  • 没有找到相关文章

最新更新