diff --git a/ivy/Ivy.scala b/ivy/Ivy.scala index 21ba28bff..22d52a6a6 100644 --- a/ivy/Ivy.scala +++ b/ivy/Ivy.scala @@ -63,8 +63,9 @@ final class IvySbt(val configuration: IvyConfiguration) configuration match { case e: ExternalIvyConfiguration => is.load(e.file) - case i: InlineIvyConfiguration => - IvySbt.configureCache(is, i.paths.cacheDirectory, i.localOnly) + case i: InlineIvyConfiguration => + i.paths.ivyHome foreach settings.setDefaultIvyUserDir + IvySbt.configureCache(is, i.localOnly) IvySbt.setResolvers(is, i.resolvers, i.otherResolvers, i.localOnly, configuration.log) IvySbt.setModuleConfigurations(is, i.moduleConfigurations) } @@ -226,9 +227,9 @@ private object IvySbt settings.addModuleConfiguration(attributes, settings.getMatcher(EXACT_OR_REGEXP), resolver.name, null, null, null) } } - private def configureCache(settings: IvySettings, dir: Option[File], localOnly: Boolean) + private def configureCache(settings: IvySettings, localOnly: Boolean) { - val cacheDir = dir.getOrElse(settings.getDefaultRepositoryCacheBasedir()) + val cacheDir = settings.getDefaultRepositoryCacheBasedir() val manager = new DefaultRepositoryCacheManager("default-cache", settings, cacheDir) { override def findModuleInCache(dd: DependencyDescriptor, revId: ModuleRevisionId, options: CacheMetadataOptions, r: String) = super.findModuleInCache(dd,revId,options,null) @@ -243,7 +244,6 @@ private object IvySbt } settings.addRepositoryCacheManager(manager) settings.setDefaultRepositoryCacheManager(manager) - dir.foreach(dir => settings.setDefaultResolutionCacheBasedir(dir.getAbsolutePath)) } def toIvyConfiguration(configuration: Configuration) = { diff --git a/ivy/IvyConfigurations.scala b/ivy/IvyConfigurations.scala index 6903c44d8..cc8bbd46f 100644 --- a/ivy/IvyConfigurations.scala +++ b/ivy/IvyConfigurations.scala @@ -6,9 +6,9 @@ package sbt import java.io.File import scala.xml.{Node, NodeSeq} -final class IvyPaths(val baseDirectory: File, val cacheDirectory: Option[File]) +final class IvyPaths(val baseDirectory: File, val ivyHome: Option[File]) { - def withBase(newBaseDirectory: File) = new IvyPaths(newBaseDirectory, cacheDirectory) + def withBase(newBaseDirectory: File) = new IvyPaths(newBaseDirectory, ivyHome) } sealed trait IvyConfiguration { diff --git a/main/actions/CacheIvy.scala b/main/actions/CacheIvy.scala index b9516ec59..c993bb710 100644 --- a/main/actions/CacheIvy.scala +++ b/main/actions/CacheIvy.scala @@ -146,7 +146,7 @@ object CacheIvy object L1 { implicit def retrieveToHL = (r: RetrieveConfiguration) => exists(r.retrieveDirectory) :+: r.outputPattern :+: HNil - implicit def ivyPathsToHL = (p: IvyPaths) => exists(p.baseDirectory) :+: p.cacheDirectory.map(exists.apply) :+: HNil + implicit def ivyPathsToHL = (p: IvyPaths) => exists(p.baseDirectory) :+: p.ivyHome.map(exists.apply) :+: HNil implicit def ivyScalaHL = (i: IvyScala) => i.scalaVersion :+: names(i.configurations) :+: i.checkExplicit :+: i.filterImplicit :+: HNil implicit def configurationToHL = (c: Configuration) => c.name :+: c.description :+: c.isPublic :+: names(c.extendsConfigs) :+: c.transitive :+: HNil diff --git a/sbt/src/sbt-test/dependency-management/artifact/project/ArtifactTest.scala b/sbt/src/sbt-test/dependency-management/artifact/project/ArtifactTest.scala new file mode 100644 index 000000000..c4cceac49 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/artifact/project/ArtifactTest.scala @@ -0,0 +1,42 @@ + import sbt._ + import Keys._ + +object ArtifactTest extends Build +{ + lazy val projects = Seq(root) + lazy val root = Project("root", file(".")) settings( + ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t))), + publishTo := Some(Resolver.file("Test Publish Repo", file("test-repo"))), + resolvers <<= (resolvers, publishTo)(_ ++ _.toList), + jarName in Compile := ArtifactName(base := artifactID, version = vers, tpe = classifier, ext = ext, cross = "", config = ""), + projectID := (if(retrieve) retrieveID else publishedID), + artifacts := artifact :: Nil + libraryDependencies ++= (if(retrieve) publishedID :: Nil else Nil), + // needed to add a jar with a different extension to the classpath + classpathFilter := "*." + ext, + check <<= checkTask + ) + + lazy val check = TaskKey[Unit]("check") + + // define strings for defining the artifact + def artifactID = "test" + def ext = "test2" + def classifier = "test3" + def tpe = "test1" + def vers = "1.1" + def org = "test" + + def artifact = Artifact(artifactID, tpe, ext, classifier) + + // define the IDs to use for publishing and retrieving + def publishedID = org % artifactID % vers artifacts(artifact) + def retrieveID = org % "test-retrieve" % "2.0" + + // check that the test class is on the compile classpath, either because it was compiled or because it was properly retrieved + def checkTask = (fullClasspath in Compile, scalaInstance) map { (cp, si) => + val loader = classpath.ClasspathUtilities.toLoader(cp.files, si.loader) + try { Class.forName("test.Test", false, loader) } + catch { case _: ClassNotFoundException | _: NoClassDefFoundError => error("Dependency not retrieved properly") } + } +} diff --git a/sbt/src/sbt-test/dependency-management/artifact/project/build.properties b/sbt/src/sbt-test/dependency-management/artifact/project/build.properties deleted file mode 100644 index 2b4d7e5a1..000000000 --- a/sbt/src/sbt-test/dependency-management/artifact/project/build.properties +++ /dev/null @@ -1,2 +0,0 @@ -project.name=Test -project.version=1.0 \ No newline at end of file diff --git a/sbt/src/sbt-test/dependency-management/artifact/project/build/ArtifactTest.scala b/sbt/src/sbt-test/dependency-management/artifact/project/build/ArtifactTest.scala deleted file mode 100644 index 71197de44..000000000 --- a/sbt/src/sbt-test/dependency-management/artifact/project/build/ArtifactTest.scala +++ /dev/null @@ -1,44 +0,0 @@ -import sbt._ - -class ArtifactTest(info: ProjectInfo) extends DefaultProject(info) -{ - // use cache specific to this test - override def ivyCacheDirectory = Some(outputPath / "ivy-cache") - - // define a test repository to publish to - override def managedStyle = ManagedStyle.Maven - val publishTo = Resolver.file("Test Publish Repo", "test-repo" asFile) - - // include the publishTo repository, which is normally excluded - override def ivyRepositories = publishTo :: Nil - - // define strings for defining the artifact - override def artifactID = "test" - def ext = "test2" - def classifier = "test3" - def tpe = "test1" - def vers = "1.1" - def org = "test" - // define the jar - override def jarPath = outputPath / (artifactID + "-" + vers + "-" + classifier + "." + ext) - def artifact = Artifact(artifactID, tpe, ext, classifier) - - // define the IDs to use for publishing and retrieving - def publishedID = org % artifactID % vers artifacts(artifact) - def retrieveID = org % "test-retrieve" % "2.0" - - override def projectID = if(retrieve) retrieveID else publishedID - override def libraryDependencies = if(retrieve) Set(publishedID) else super.libraryDependencies - - // switches between publish and retrieve mode - def retrieve = "retrieve".asFile.exists - // needed to add a jar with a different extension to the classpath - override def classpathFilter = "*." + ext - - // check that the test class is on the compile classpath, either because it was compiled or because it was properly retrieved - lazy val check = task { check0 } - def check0 = - try { Class.forName("test.Test", false, loader); None } - catch { case _: ClassNotFoundException | _: NoClassDefFoundError => Some("Dependency not retrieved properly") } - def loader = ClasspathUtilities.toLoader(compileClasspath, buildScalaInstance.loader) -}