Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override sbt default resolvers with authenticated repo?

Tags:

scala

sbt

I have a maven repository with authentication, and I want sbt to use only the maven repository

My build.sbt:

resolvers += "My Repo" at "https://my.repository.addresss/repo/"

externalResolvers <<= resolvers map { rs =>
    Resolver.withDefaultResolvers(rs, mavenCentral = false)
}

But when I type sbt clean compile, it is still download from repo1.maven.org, I can not override it!

As my maven repo has to authenticate, so it always fails when I put default repo config in ~/.sbt/repositories

Is there any way that I can use my repo only, and authenticate successful?

like image 980
jiluo Avatar asked Jun 05 '13 11:06

jiluo


2 Answers

Unfortunately, I can only help you with one part of your question.

If you only want to use your maven repo, have a look at the sbt documentation, chapter proxy repositories. There the file ~/.sbt/repositories is used. Alternatively, you can also use sbt.boot.properties (see Launcher configuration).

Don't forget to override the build repos from the build scripts as documented here. If you don't do that, sbt still tries to connect to repo1.maven.org.

I did the same thing today (using sbt 0.12.3), and it works!

like image 196
Christian Avatar answered Oct 21 '22 17:10

Christian


Try this:

lazy val yourRepo = "yourRepo" at "https://yourRepo.com/nexus/content/groups/public"

fullResolvers := {
    val oldResolvers = fullResolvers.value
    val idx = oldResolvers.map(_.isInstanceOf[DefaultMavenRepository$]).indexOf(true)
    oldResolvers.take(idx) ++ Seq(yourRepo) ++ oldResolvers.drop(idx)
}
like image 1
Raven Avatar answered Oct 21 '22 17:10

Raven