背景:我们公司有几个Play!应用程序,它们的测试在我们的内部 CI 中运行。每个 Play 应用程序都通过 http 从各种公共存储库中检索依赖项。这并不理想(它绕过了我们内部的 Nexus 存储库)但可以忍受。现在我们正在添加额外的 CI 容量,并且不希望让新机器能够访问防火墙之外。
在示例 Play 应用程序中,以下配置project/Build.scala
不足以阻止构建转到repo.typesafe.com
and repo1.maven.org
:
sbtResolver := "Typesafe (proxy)" at "http://repo-1/nexus/content/repositories/typesafe-releases/"
resolvers := Seq(
"Maven Central (proxy)" at "http://repo-1/nexus/content/repositories/central/",
"Typesafe (proxy)" at "http://repo-1/nexus/content/repositories/typesafe-releases/",
// some more internal Nexus repositories
)
externalResolvers := Seq.empty
(repo-1
是我们内部的 Nexus 主机,它代理 Maven Central、Typesafe 和其他存储库)
当我从 Maven Central(例如 Guava)或 Typesafe 的存储库(例如 Play mailer 插件)中删除一些依赖项并运行play compile
时,我从输出中看到仍在从repo.typesafe.com
和检索依赖项repo1.maven.org
:
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play-plugins-mailer_2.9.1/2.0.2/play-plugins-mailer_2.9.1-2.0.2.jar ...
[info] [SUCCESSFUL ] com.typesafe#play-plugins-mailer_2.9.1;2.0.2!play-plugins-mailer_2.9.1.jar (981ms)
[info] downloading http://repo1.maven.org/maven2/com/google/guava/guava/12.0/guava-12.0.jar ...
[info] [SUCCESSFUL ] com.google.guava#guava;12.0!guava.jar (1422ms)
更复杂的是,我们还使用了稍旧的所有版本:Scala 2.9.1、Play 2.0.1、sbt 0.11.3。
如何强制 Play 应用仅从内部存储库中检索依赖项?