Scala Coursier 自定义 Ivy 仓库

5

我希望尝试使用coursier artifact fetcher,但是我们正在使用Artifactory进行maven和ivy仓库管理,我不确定如何在coursier中设置它。在文档中,他们提供了以下环境变量的示例:

export COURSIER_REPOSITORIES="ivy2Local|central|sonatype:releases|jitpack|https://corporate.com/repo"

如果我有一个带有以下URL的Artifactory Ivy仓库:http://myivyrepo.tld/joint-ivy-releases,同时还有一些自定义模式:
[org]/[module]/[baseRev](-[folderItegRev])/[module]-[baseRev](-[fileItegRev])(-[classifier]).[ext]

我该如何使用Coursier设置这个?

1个回答

0

我已经为了使这个工作而努力了太多,我知道这个问题两年前就提出了,但我认为我们可以从回答它中受益。

根据Coursier的cs fetch --help

  --repository | -r  <maven|sonatype:$repo|ivy2local|bintray:$org/$repo|bintray-ivy:$org/$repo|typesafe:ivy-$repo|typesafe:$repo|sbt-plugin:$repo|scala-integration|scala-nightlies|ivy:$pattern|jitpack|clojars|jcenter|apache:$repo>
        Repository - for multiple repositories, separate with comma and/or add this option multiple times (e.g. -r central,ivy2local -r sonatype:snapshots, or equivalently -r central,ivy2local,sonatype:snapshots)

(也许在提出这个问题时不是这种情况)可以在Ivy存储库前缀中加入ivy。从这个帮助文档中真正不清楚的是如何同时提供自定义服务器和模式,但实际上非常简单,您必须将两者连接在参数中:
cs fetch --no-default --repository http://myivyrepo.tld/joint-ivy-releases/[org]/[module]/[baseRev](-[folderItegRev])/[module]-[baseRev](-[fileItegRev])(-[classifier]).[ext]

Coursier的内部解析器将负责检测哪部分是URL,哪部分是模式。
如果有人感兴趣,所有负责的代码都位于coursier中的IvyRepository.parse函数中。
此外,可以向coursier提供metadataPattern(我不知道那是什么)来为ivy分隔它们,方法是在后面加上一个|。
cs fetch --no-default --repository http://myivyrepo.tld/joint-ivy-releases/[org]/[module]/[baseRev](-[folderItegRev])/[module]-[baseRev](-[fileItegRev])(-[classifier]).[ext]|<YOUR_METADATA_OPTS>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接