Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Readonly file ProjectRef #120

Merged
merged 1 commit into from

2 participants

@duboisf

This allows using a project reference that points to a readonly
directory.

The use case for this is having sbt plugin projects on a network
share (readonly) that you can just point to. The plugin projects
get copied and built automatically, just like a git project
reference gets cloned and built.

This will ease plugin imcompatibilies between minor sbt versions,
avoiding to have to cross build plugins against all compatible sbt
versions.

@harrah
Owner

Use git rebase upstream/0.10 to clean up the history so that only your commit shows up. Otherwise, it looks fine.

@duboisf duboisf Support for readonly file ProjectRef
This allows using a project reference that points to a readonly
directory.

The use case for this is having sbt plugin projects on a network
share (readonly) that you can just point to. The plugin projects
get copied and built automatically, just like a git project
reference gets cloned and built.

This will ease plugin imcompatibilies between minor sbt versions,
avoiding to have to cross build plugins against all compatible sbt
versions.
4ffe240
@duboisf

Thanks, I was wondering why there were more then 1 commit. From now on I'll rebase upstream instead of merging.

@harrah harrah merged commit 671053c into from
@harrah
Owner

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 24, 2011
  1. @duboisf

    Support for readonly file ProjectRef

    duboisf authored
    This allows using a project reference that points to a readonly
    directory.
    
    The use case for this is having sbt plugin projects on a network
    share (readonly) that you can just point to. The plugin projects
    get copied and built automatically, just like a git project
    reference gets cloned and built.
    
    This will ease plugin imcompatibilies between minor sbt versions,
    avoiding to have to cross build plugins against all compatible sbt
    versions.
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 1 deletion.
  1. +20 −1 main/Build.scala
View
21 main/Build.scala
@@ -46,10 +46,29 @@ object RetrieveUnit
case "http" | "https" => Some { () => downloadAndExtract(base, tmp); tmp }
case "file" =>
val f = new File(base)
- if(f.isDirectory) Some(() => f) else None
+ if(f.isDirectory)
+ {
+ val finalDir = if (!f.canWrite) retrieveRODir(f, tmp) else f
+ Some(() => finalDir)
+ }
+ else None
case _ => None
}
}
+ def retrieveRODir(base: File, tempDir: File): File =
+ {
+ if (!tempDir.exists)
+ {
+ try {
+ IO.copyDirectory(base, tempDir)
+ } catch {
+ case e =>
+ IO.delete(tempDir)
+ throw e
+ }
+ }
+ tempDir
+ }
def downloadAndExtract(base: URI, tempDir: File): Unit = if(!tempDir.exists) IO.unzipURL(base.toURL, tempDir)
def temporary(tempDir: File, uri: URI): File = new File(tempDir, Hash.halve(hash(uri)))
def hash(uri: URI): String = Hash.toHex(Hash(uri.toASCIIString))
Something went wrong with that request. Please try again.