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
This commit is contained in:
dmharrah 2009-09-27 23:00:27 +00:00
parent 1cee3e8542
commit 42b343ca9a
2 changed files with 11 additions and 3 deletions

View File

@ -623,7 +623,7 @@ object ManageDependencies
import XmlModuleDescriptorParser.Parser import XmlModuleDescriptorParser.Parser
class CustomParser(settings: IvySettings, defaultConfig: Option[String]) extends Parser(CustomXmlParser, settings) with NotNull 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) = def setSource(url: URL) =
{ {

View File

@ -260,7 +260,7 @@ object Resolver
/** Constructs a file resolver with the given name and base directory. */ /** Constructs a file resolver with the given name and base directory. */
def apply(name: String, baseDirectory: File)(implicit basePatterns: Patterns): FileRepository = 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, _)) baseRepository(baseDirectory.toURI)(FileRepository(name, defaultFileConfiguration, _))
} }
} }
@ -274,7 +274,7 @@ object Resolver
baseRepository(baseURL.toURI)(URLRepository(name, _)) baseRepository(baseURL.toURI)(URLRepository(name, _))
} }
private def baseRepository[T](baseURI: java.net.URI)(construct: Patterns => T)(implicit basePatterns: Patterns): T = 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. /** If `base` is None, `patterns` is returned unchanged.
* Otherwise, the ivy file and artifact patterns in `patterns` are resolved against the given base. */ * 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) def resolveAll(patterns: Seq[String]) = patterns.map(resolve)
Patterns(resolveAll(basePatterns.ivyPatterns), resolveAll(basePatterns.artifactPatterns), basePatterns.isMavenCompatible) 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.*/ /** 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) private def pathURI(path: String) = new URI(null, null, path, null)