Playframework 2.1 slow resolving of internal depen

2019-08-05 05:26发布

We're using a in house sonatype repository for our own libraries which our play project depend upon. Lately the project have been taking around 10 minutes to start (using play run) because the resolving is slow.

Trying to see what's happening I'm running a ngrep port 80. I see alot of slow responses from the typesafe repository which answer that our own libraries isn't in their repo.

Example:

T <my-internal-ip>:41907 -> 54.236.91.228:80 [AP]
  HEAD /typesafe/snapshots/<our-pom-file-here> HT
  TP/1.1..User-Agent: Apache Ivy/2.3.0-rc1..Host: repo.typesafe.com..Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2..Connection: keep-alive....                                         
#########
T 54.236.91.228:80 -> <my-iternal-ip>:41907 [AP]
  HTTP/1.1 404 Not Found..Content-Type: application/json;charset=ISO-8859-1..Date: Wed, 07 May 2014 
  14:10:32 GMT..Server: Artifactory/3.2.0..X-Artifactory-Id: typesafe2-use-1e-typesafereadonly..Connection: keep-alive.... 

So I would like sbt to search our own repository first which it dosen't seem to be doing at the moment. We've added our repositories in Build.scala like:

val main = play.Project(appName, appVersion, appDependencies)
[...]
.settings(
  [...]
  resolvers += "nexus" at "<URL>",
  [...]

Any suggestions how to tell sbt to search our local repos before trying with typesafe?

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-08-05 06:08

You have to override the resolvers. Currently you're appending your repository after the Type Safe's resolver. You can type show resolvers to show the list of currently declared resolvers.

If you want your repository to come before typesafe you have to replace the current list. Instead of += override the key by either := (SBT 0.13.x or newer) or ~= for older SBT versions.

Play 2.1.x (SBT 0.12.x)

resolvers ~= ( resolvers => ("My Company Releases" at "http://mycompany.com/releases") +: resolvers)

Play 2.2.x (SBT 0.13 or greater)

resolvers := ("My Company Releases" at "http://mycompany.com/releases") +: resolvers.value

This will not override all resolvers. There are also externalResolvers, which may be overridden as it is described in the documentation

查看更多
Lonely孤独者°
3楼-- · 2019-08-05 06:15

You can use routing rules to preclude the typesafe repo from being hit for internal components. The system actually ships with a few sample org.company | com.company examples for this exact case. http://books.sonatype.com/nexus-book/reference/confignx-sect-managing-routes.html

Also if you are using a group repository, you can order your local repos above all the external ones because the cost to resolve is much lower. There are cases where routing still helps so for internal components you should do both.

查看更多
登录 后发表回答