Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change SBT's rules on generating URLs for Maven repositories?

Tags:

maven

scala

sbt

By default, the Scala Built Tool (SBT) has a set of rules on how to generate URLs when looking up dependencies. For example, if I have the following build file,

// Project settings
name := "MyProject"

version := "0.1"

organization := "com.me"

scalaVersion := "2.8.1"

// Dependencies
libraryDependencies ++= Seq(
   "com.google.guava" %% "guava" % "r09"
)

// Repositories
resolvers += "Maven Central Server" at "http://repo1.maven.org/maven2"

Then SBT attempts to find guava at the following URL,

http://repo1.maven.org/maven2/com/google/guava/guava_2.8.1/r09/guava_2.8.1-r09.pom

However, the library I'm looking for in this case isn't even made for Scala, so combining the Scala version just doesn't make sense here. How can I tell SBT what the format is for generating URLs for use with Maven repositories?

EDIT

While it seems that it is possible to edit the layout like so,

Resolver.url("Primary Maven Repository",
    new URL("http://repo1.maven.org/maven2/"))( Patterns("[organization]/[module]/[module]-[revision].[ext]") )

the "[module]" keyword is predefined to be the (artifact id)_(scala version) and the "[artifact]" keyword is just "ivy", leaving me back at square one.

like image 452
duckworthd Avatar asked Aug 04 '11 06:08

duckworthd


2 Answers

As far as I remember "%%" appends the scala version and "%" does not. Try

libraryDependencies ++= Seq(
    "com.google.guava" % "guava" % "r09"
)
like image 69
Jan Avatar answered Oct 04 '22 17:10

Jan


Check last one paragraph (Custom Layout) of official sbt wiki here.

Basically SBT allows you to use this syntax:

resolvers += Resolver.url("my-test-repo", url)( Patterns("[organisation]/[module]/[revision]/[artifact].[ext]") )
like image 24
om-nom-nom Avatar answered Oct 04 '22 15:10

om-nom-nom