From 42b343ca9a59f593e583027b4b6feccb59c0fc6e Mon Sep 17 00:00:00 2001 From: dmharrah Date: Sun, 27 Sep 2009 23:00:27 +0000 Subject: [PATCH] Fix issue where last path component of local repository was dropped if it did not exist. git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@1057 d89573ee-9141-11dd-94d4-bdf5e562f29c --- src/main/scala/sbt/ManageDependencies.scala | 2 +- src/main/scala/sbt/ManagedInterface.scala | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/scala/sbt/ManageDependencies.scala b/src/main/scala/sbt/ManageDependencies.scala index 368c92502..6d462a2cb 100644 --- a/src/main/scala/sbt/ManageDependencies.scala +++ b/src/main/scala/sbt/ManageDependencies.scala @@ -623,7 +623,7 @@ object ManageDependencies import XmlModuleDescriptorParser.Parser class CustomParser(settings: IvySettings, defaultConfig: Option[String]) extends Parser(CustomXmlParser, settings) with NotNull { - defaultConfig.foreach(x => setDefaultConfMapping("*->default(compile)")) + if(defaultConfig.isDefined) setDefaultConfMapping("*->default(compile)") def setSource(url: URL) = { diff --git a/src/main/scala/sbt/ManagedInterface.scala b/src/main/scala/sbt/ManagedInterface.scala index 6af59f830..b7c890337 100644 --- a/src/main/scala/sbt/ManagedInterface.scala +++ b/src/main/scala/sbt/ManagedInterface.scala @@ -260,7 +260,7 @@ object Resolver /** Constructs a file resolver with the given name and base directory. */ def apply(name: String, baseDirectory: File)(implicit basePatterns: Patterns): FileRepository = { - if(baseDirectory.exists && !baseDirectory.isDirectory) error("Not a directory: " + baseDirectory.getAbsolutePath) else baseDirectory.mkdirs() + if(baseDirectory.exists && !baseDirectory.isDirectory) error("Not a directory: " + baseDirectory.getAbsolutePath) baseRepository(baseDirectory.toURI)(FileRepository(name, defaultFileConfiguration, _)) } } @@ -274,7 +274,7 @@ object Resolver baseRepository(baseURL.toURI)(URLRepository(name, _)) } private def baseRepository[T](baseURI: java.net.URI)(construct: Patterns => T)(implicit basePatterns: Patterns): T = - construct(resolvePatterns(baseURI.normalize, basePatterns)) + construct(resolvePatterns(normalize(baseURI), basePatterns)) /** If `base` is None, `patterns` is returned unchanged. * Otherwise, the ivy file and artifact patterns in `patterns` are resolved against the given base. */ @@ -291,6 +291,14 @@ object Resolver def resolveAll(patterns: Seq[String]) = patterns.map(resolve) Patterns(resolveAll(basePatterns.ivyPatterns), resolveAll(basePatterns.artifactPatterns), basePatterns.isMavenCompatible) } + /** Normalizes the given URI, which is assumed to represent a directory, even if that directory does not exist. This method exists + * because URI.normalize does not append a slash if the directory does not exist.*/ + private def normalize(uri: URI) = + { + val normalized = uri.normalize + val normString = normalized.toString + if(normString.endsWith("/")) normalized else new URI(normString + "/") + } /** Constructs a `URI` with the path component set to `path` and the other components set to null.*/ private def pathURI(path: String) = new URI(null, null, path, null)