diff --git a/build.sbt b/build.sbt index 2bb66c9bd..af48ed518 100644 --- a/build.sbt +++ b/build.sbt @@ -1201,7 +1201,11 @@ def otherRootSettings = scriptedUnpublished := scriptedUnpublishedTask.evaluated, scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test", watchTriggers in scripted += scriptedSource.value.toGlob / **, - scriptedLaunchOpts := List("-Xmx1500M", "-Xms512M", "-server"), + scriptedLaunchOpts := List("-Xmx1500M", "-Xms512M", "-server") ::: + (sys.props.get("sbt.ivy.home") match { + case Some(home) => List(s"-Dsbt.ivy.home=$home") + case _ => Nil + }), publishAll := { val _ = (publishLocal).all(ScopeFilter(inAnyProject)).value }, publishLocalBinAll := { val _ = (publishLocalBin).all(ScopeFilter(inAnyProject)).value }, aggregate in bintrayRelease := false @@ -1213,7 +1217,11 @@ def otherRootSettings = "-server", "-Dsbt.override.build.repos=true", s"""-Dsbt.repository.config=${scriptedSource.value / "repo.config"}""" - ), + ) ::: + (sys.props.get("sbt.ivy.home") match { + case Some(home) => List(s"-Dsbt.ivy.home=$home") + case _ => Nil + }), scripted := scriptedTask.evaluated, scriptedUnpublished := scriptedUnpublishedTask.evaluated, scriptedSource := (sourceDirectory in sbtProj).value / "repo-override-test" diff --git a/sbt/src/test/scala/sbt/RunFromSourceMain.scala b/sbt/src/test/scala/sbt/RunFromSourceMain.scala index dfc694fc3..ec7b168aa 100644 --- a/sbt/src/test/scala/sbt/RunFromSourceMain.scala +++ b/sbt/src/test/scala/sbt/RunFromSourceMain.scala @@ -26,6 +26,10 @@ object RunFromSourceMain { def fork(fo0: ForkOptions, workingDirectory: File): Process = { val fo = fo0 .withWorkingDirectory(workingDirectory) + .withRunJVMOptions(sys.props.get("sbt.ivy.home") match { + case Some(home) => Vector(s"-Dsbt.ivy.home=$home") + case _ => Vector() + }) implicit val runner = new ForkRun(fo) val cp = { TestBuildInfo.test_classDirectory +: TestBuildInfo.fullClasspath @@ -117,7 +121,10 @@ object RunFromSourceMain { def topLoader = new java.net.URLClassLoader(Array(), null) def globalLock = noGlobalLock def bootDirectory = RunFromSourceMain.bootDirectory - def ivyHome = file(sys.props("user.home")) / ".ivy2" + def ivyHome: File = sys.props.get("sbt.ivy.home") match { + case Some(home) => file(home) + case _ => file(sys.props("user.home")) / ".ivy2" + } case class PredefRepo(id: Predefined) extends PredefinedRepository import Predefined._ def ivyRepositories = Array(PredefRepo(Local), PredefRepo(MavenCentral))