Reputation: 2346
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?
Upvotes: 15
Views: 7665
Reputation: 1295
I've met similar situation of yours. The solution is
create ~/.ivy2/.credentials
with
realm=Sonatype Nexus Repository Manager
host=yourRepo.com
user=yourUser
password=yourpassword
add this line to build.sbt
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
create ~/.sbt/repositories
according to http://www.scala-sbt.org/1.0/docs/Proxy-Repositories.html
Upvotes: 0
Reputation: 11
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)
}
Upvotes: 1
Reputation: 4593
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!
Upvotes: 6