SBT:无法发布到Apache Archiva

时间:2014-01-06 19:52:43

标签: scala maven sbt archiva

错误讯息:

   java.io.IOException: Access to URL 
   http://maven.company.com/repository/internal/com/company/
   project_2.10/0.0.3/project_2.10-0.0.3.pom was
   refused by the server: Unauthorized

运行Apache Archiva 1.4-M4(最新版),我可以通过网络界面上传,但不能通过SBT上传。

在SBT中使用这些设置:

 publishTo := Some("company releases" at "http://maven.company.com/repository/internal"),
   credentials += Credentials(
     "company Maven Repository",
          "maven.company.com",
          "username",
          "password"
        ),
   publishMavenStyle := true,
   publishArtifact in Test := false,
   pomIncludeRepository := { _ => true },
   // .. some xml with author details
 }

所有详细信息,包括用户名,密码和网址都是正确的。

1 个答案:

答案 0 :(得分:6)

安全王国对常春藤很重要。它就像是唯一要求您使用有效安全领域的依赖管理器。我相信apache archiva是“Repository Archiva Managed”。您可以通过尝试向Archiva发出自己的HTTP请求进行检查,并查看它支持的Realms。

以下是尝试检测安全领域的代码:https://github.com/sbt/sbt-pom-reader/blob/2b515b58739ef7bdfad8f98248e901db8e140892/src/main/scala/com/typesafe/sbt/pom/MavenHelper.scala#L212-L221

<强>更新: 领域看起来像:“Repository Archiva Managed internal Repository”。如果您发布到其他repos,请将“internal”替换为repo的名称。

确定安全领域后,您需要按如下方式更新构建:

  credentials += Credentials(
      "Repository Archiva Managed internal Repository",  // Or whatever you detect as the security realm
      "maven.company.com",
      "username",
      "password"
    ),