Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a copy of the .ivy2 cache as SBT resolver source

Tags:

scala

sbt

ivy

I'm trying to package a few in-house artifacts for use with SBT. I would just use the libs directory in most cases, but there are multiple projects that share the same artifacts.

I've been trying to use the directory structure that is produced by SBT as a basis for this small repository. It stores the artifacts in .ivy2 like so:

.ivy2/cache/[org-with-dots]/[module]/[artifact]-[version].[ext]

I've copied the stuff i need under cache to it's own folder and then tried the following patterns in SBT to no avail:

resolvers += "cache" at "file:/../ivy-cache"
resolvers += Resolver.file("cache", file("../ivy-cache"))
resolvers += Resolver.file("cache", file("../ivy-cache"))(Resolver.ivyStylePatterns)
resolvers += Resolver.file("cache", file("../ivy-cache"))(Patterns("[organization]/[module]/[artifact]-[revision].[ext]"))

None of these work. The closest was the last one, but organization comes out with slashes instead of dots. The Resolver.ivyStylePatterns used dots in the organization, but expected a folder called ivys to be used.

So I have a two part question:

  1. Should I just be doing something else to capture these locally hosted artifacts? Im not building them, so publish is not desirable.
  2. Is there a way to specify the pattern I want above without doing a string replacement from / to . in the organization component?
like image 948
Rich Henry Avatar asked Jan 05 '16 19:01

Rich Henry


1 Answers

Found the answer, Pattern has an apply overload which takes a boolean parameter for its first argument. When true it uses a Maven style organization string which uses slashes to separate the components, when false it uses Ivy style (dots).

Here's what worked (with SBT 0.3.9):

resolvers += Resolver.file("cache", file("../ivy-cache"))(Patterns(false,"[organization]/[module]/[artifact]-[revision].[ext]"))

PS: if someone provides a better workflow instead, i will accept that over this answer...

like image 130
Rich Henry Avatar answered Oct 11 '22 17:10

Rich Henry