Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(SBT) How to disable default resolver and only use the company internal resolver?

We want to use company internal ivy/maven repository (artifactory) to improve the speed of resolving, and downloading the jar files, and also we want to use it to exchange binary jar files between different teams in our organization.

I know we can force SBT to go through proxy by setting ~/.repositories with

[repositories]
  local
  my-ivy-proxy-releases: http://repo.alpinenow.com/artifactory/repo/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
  my-maven-proxy-releases: http://repo.alpinenow.com/artifactory/repo/

and then launch SBT with -Dsbt.override.build.repos=true. This method works for me.

However, it's kind of cumbersome to ask all the developers to setup this way. We're wondering if we can override the default resolvers completely in Build.scala, and plugin.sbt without extra configuration.

So far, I've tried the following ways without success.

1) In both Build.scala and plugin.sbt, I added

resolvers := "Local Repo" at "http://repo.alpinenow.com/artifactory/repo/",

externalResolvers := Seq(Resolver.url("Local Repo", url("http://repo.alpinenow.com/artifactory/repo"))(Resolver.ivyStylePatterns)),

but it still downloads the jars from typesafe and maven1.

2) I then decided to put repositories file into project folder, and tried to add java option directly inside plugin.sbt, and Build.scala with

System.setProperty("-Dsbt.override.build.repos", "true"),

System.setProperty("-Dsbt.repository.config", "project/repositories"),

but it still doesn't work. I'm curious when the SBT gets the java options for resolvers since obviously, it's before plugin.sbt and Build.scala.

Any idea?

Thanks.

DB Tsai

like image 542
DB Tsai Avatar asked Oct 25 '13 08:10

DB Tsai


1 Answers

Project level

According to the documentation we should be using externalResolvers:
https://www.scala-sbt.org/release/docs/Library-Dependencies.html#Overriding+default+resolvers

externalResolvers := Seq(
  "Local Repo" at "http://repo.alpinenow.com/artifactory/repo/",
  // some more internal Nexus repositories
)

Plugin level

You'll have to do it also in your project folder for plugins like in project/resolvers.sbt.

Global SBT level

And if you also want SBT it self to resolve from a specific repo, you'll need to do as described here: https://www.scala-sbt.org/1.x/docs/Proxy-Repositories.html

like image 103
Joan Avatar answered Nov 11 '22 11:11

Joan