質問

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

役に立ちましたか?

解決 2

If you depart from the sbt-extras shell script as a replacement for the default launcher script, I guess you could easily modify that with setting up ~/.repositories and adding -Dsbt.override.build.repos=true. Then all you need to do is ensure your developers use that script.

他のヒント

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

I am always adding SBT build as part of my repo in SVN/GIT, close with code. Then I have no such problems.

It costs about 1MB space so is quite cheap and solves a lot of problems. All developers use identical build tool. Even if I try to create Continues Integration or more advanced Continues Delivery process all SBT configs will be already well configured in my SCM. I will get one source of true :)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top