15

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?

5
  • I tested your config with inspect resolvers and show external-resolvers. It show me absolutely proper values without mavenCentral. IMHO you may open bug ticket in your case at github.com/sbt/sbt-git.
    – Ezhik
    Commented Jun 6, 2013 at 7:16
  • github.com/sbt/sbt of course
    – Ezhik
    Commented Jun 6, 2013 at 7:24
  • 1
    @Ezhik although it does show the proper values, but still download from repo1.maven.org when sbt compile
    – jiluo
    Commented Jun 6, 2013 at 9:15
  • stackoverflow.com/questions/3770125/… - I think this is an answer for your question. But if you post a bug report it would be right.
    – Ezhik
    Commented Jun 6, 2013 at 16:50
  • Possible duplicate of How to access a secured Nexus with sbt?
    – Mo Tao
    Commented Jan 4, 2017 at 7:30

3 Answers 3

6

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!

1

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)
}
0

I've met similar situation of yours. The solution is

  1. create ~/.ivy2/.credentials with

    realm=Sonatype Nexus Repository Manager
    host=yourRepo.com
    user=yourUser
    password=yourpassword
    
  2. add this line to build.sbt

    credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
    
  3. create ~/.sbt/repositories according to http://www.scala-sbt.org/1.0/docs/Proxy-Repositories.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.