how do I get sbt to use a local maven proxy repository (Nexus)?

后端 未结 6 1195
無奈伤痛
無奈伤痛 2020-11-27 10:50

I\'ve got an sbt (Scala) project that currently pulls artifacts from the web. We\'d like to move towards a corporate-standardized Nexus repository that would cache artifacts

6条回答
  •  时光取名叫无心
    2020-11-27 11:20

    OK, with some help from Mark Harrah on the sbt mailing list, I have an answer that works.

    My build class now looks like the following (plus some other repos):

    import sbt._
    
    //By extending DefaultWebProject, we get Jetty support
    class OurApplication(info: ProjectInfo) extends DefaultWebProject(info) {
    
      // This skips adding the default repositories and only uses the ones you added
      // explicitly. --Mark Harrah
      override def repositories = Set("OurNexus" at "http://our.nexus.server:9001/nexus/content/groups/public/") 
      override def ivyRepositories = Seq(Resolver.defaultLocal(None)) ++ repositories
    
      /* Squeryl */
      val squeryl = "org.squeryl" % "squeryl_2.8.0.RC3" % "0.9.4beta5"
    
      /* DATE4J */
      val date4j = "hirondelle.date4j" % "date4j" % "1.0" from "http://www.date4j.net/date4j.jar"
    
      // etc
    }
    

    Now, if I delete the Squeryl tree from my machine's .ivy2/cache directory, sbt tries to grab it from the Nexus tree with the appropriate URL. Problem solved!

提交回复
热议问题