Warm tip: This article is reproduced from stackoverflow.com, please click
playframework sbt typesafe-stack maven-central typesafe

How to remove all default resolvers from a Play! application?

发布于 2020-03-27 10:26:00

Background: our company has several Play! apps, which have their tests run in our internal CI. Each Play application retrieves dependencies from various public repositories over http. This has not been ideal (it bypasses our internal Nexus repository) but bearable. Now we are adding extra CI capacity, and do not want to allow the new machines to be able to access outside the firewall.

In an example Play app, the following configuration in project/Build.scala is not enough to prevent the build going to 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 is our internal Nexus host, which proxies Maven Central, Typesafe, and others repositories)

When I remove some dependencies, either from Maven Central (e.g. Guava) or from Typesafe's repository (e.g. the Play mailer plugin), and run play compile, I see from the output that the dependencies are still being retrieved from repo.typesafe.com and 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)

To compound the problem, we're also on slightly older versions of everything: Scala 2.9.1, Play 2.0.1, sbt 0.11.3.


How do I force a Play app to retrieve dependencies from an internal repository, exclusively?

Questioner
Grundlefleck
Viewed
49
vizog 2014-05-08 15:11

Edit or create /home/YOUR_HOME/.sbt/repositories add the following:

[repositories] local my-maven-proxy-releases: http://nexus_domain_or_ip:8081/nexus/content/groups/public/

when running play add this parameter: -Dsbt.override.build.repos=true

e.g: activator run -Dsbt.override.build.repos=true

This prevents play from loading the repositories defined in project configs.

See this for details.