【问题标题】:Override sbt default resolvers with authenticated repo?使用经过身份验证的 repo 覆盖 sbt 默认解析器?
【发布时间】:2013-06-01 02:45:36
【问题描述】:

我有一个带身份验证的 maven 存储库,我希望 sbt 只使用 maven 存储库

我的 build.sbt:

resolvers += "My Repo" at "https://my.repository.addresss/repo/"

externalResolvers <<= resolvers map { rs =>
    Resolver.withDefaultResolvers(rs, mavenCentral = false)
}

但是当我输入sbt clean compile时,它仍然是从repo1.maven.org下载的,我无法覆盖它!

由于我的 maven repo 必须进行身份验证,所以当我将默认 repo 配置放入 ~/.sbt/repositories 时它总是失败

有什么方法可以让我只使用我的 repo 并且验证成功?

【问题讨论】:

标签: scala sbt


【解决方案1】:

很遗憾,我只能帮你解决一部分问题。

如果您只想使用您的 maven 存储库,请查看 sbt 文档,章节 proxy repositories。那里使用了文件 ~/.sbt/repositories。或者,您也可以使用 sbt.boot.properties(请参阅Launcher configuration)。

不要忘记按照here 的文档覆盖构建脚本中的构建存储库。如果 你不这样做,sbt 仍然尝试连接到 repo1.maven.org。

我今天做了同样的事情(使用 sbt 0.12.3),它有效!

【讨论】:

    【解决方案2】:

    试试这个:

    lazy val yourRepo = "yourRepo" at "https://yourRepo.com/nexus/content/groups/public"
    
    fullResolvers := {
        val oldResolvers = fullResolvers.value
        val idx = oldResolvers.map(_.isInstanceOf[DefaultMavenRepository$]).indexOf(true)
        oldResolvers.take(idx) ++ Seq(yourRepo) ++ oldResolvers.drop(idx)
    }
    

    【讨论】:

      【解决方案3】:

      我遇到过你的类似情况。解决办法是

      1. 创建~/.ivy2/.credentials
        realm=Sonatype Nexus Repository Manager
        host=yourRepo.com
        user=yourUser
        password=yourpassword
        
      2. 将此行添加到build.sbt

        credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
        
      3. 根据http://www.scala-sbt.org/1.0/docs/Proxy-Repositories.html创建~/.sbt/repositories

      【讨论】:

        猜你喜欢
        • 2019-05-22
        • 1970-01-01
        • 2019-03-02
        • 2022-01-08
        • 1970-01-01
        • 2019-02-16
        • 1970-01-01
        • 2022-11-09
        • 1970-01-01
        相关资源
        最近更新 更多