diff --git a/.travis.yml b/.travis.yml index 486022e06..4a9e3a500 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,8 @@ env: - SBT_CMD="scripted source-dependencies/*3of3" - SBT_CMD="scripted tests/*" - SBT_CMD="scripted project-load/*" + - SBT_CMD="checkBuildScala211" + - SBT_CMD="repoOverrideTest:scripted dependency-management/*" notifications: email: diff --git a/build.sbt b/build.sbt index 5d0032ed2..59dc41b35 100644 --- a/build.sbt +++ b/build.sbt @@ -202,16 +202,21 @@ lazy val sbtProj = (project in sbtPath). def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask { val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed publishAll.value + // These two projects need to be visible in a repo even if the default + // local repository is hidden, so we publish them to an alternate location and add + // that alternate repo to the running scripted test (in Scripted.scriptedpreScripted). + // (altLocalPublish in interfaceProj).value + // (altLocalPublish in compileInterfaceProj).value Scripted.doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value, (scalaInstance in scriptedSbtProj).value, - scriptedSource.value, scriptedBufferLog.value, result, scriptedPrescripted.value) + scriptedSource.value, scriptedBufferLog.value, result, scriptedPrescripted.value, scriptedLaunchOpts.value) } def scriptedUnpublishedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask { val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed Scripted.doScripted((sbtLaunchJar in bundledLauncherProj).value, (fullClasspath in scriptedSbtProj in Test).value, (scalaInstance in scriptedSbtProj).value, - scriptedSource.value, scriptedBufferLog.value, result, scriptedPrescripted.value) + scriptedSource.value, scriptedBufferLog.value, result, scriptedPrescripted.value, scriptedLaunchOpts.value) } lazy val publishLauncher = TaskKey[Unit]("publish-launcher") @@ -233,11 +238,40 @@ def otherRootSettings = Seq( scripted <<= scriptedTask, scriptedUnpublished <<= scriptedUnpublishedTask, scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test", + // scriptedPrescripted := { addSbtAlternateResolver _ }, + scriptedLaunchOpts := List("-XX:MaxPermSize=256M", "-Xmx1G"), publishAll := { val _ = (publishLocal).all(ScopeFilter(inAnyProject)).value }, aggregate in bintrayRelease := false -) +) ++ inConfig(Scripted.RepoOverrideTest)(Seq( + scriptedPrescripted := { _ => () }, + scriptedLaunchOpts := { + List("-XX:MaxPermSize=256M", "-Xmx1G", "-Dsbt.override.build.repos=true", + s"""-Dsbt.repository.config=${ scriptedSource.value / "repo.config" }""") + }, + scripted <<= scriptedTask, + scriptedUnpublished <<= scriptedUnpublishedTask, + scriptedSource := (sourceDirectory in sbtProj).value / "repo-override-test" +)) + +// def addSbtAlternateResolver(scriptedRoot: File) = { +// val resolver = scriptedRoot / "project" / "AddResolverPlugin.scala" +// if (!resolver.exists) { +// IO.write(resolver, s"""import sbt._ +// |import Keys._ +// | +// |object AddResolverPlugin extends AutoPlugin { +// | override def requires = sbt.plugins.JvmPlugin +// | override def trigger = allRequirements +// | +// | override lazy val projectSettings = Seq(resolvers += alternativeLocalResolver) +// | lazy val alternativeLocalResolver = Resolver.file("$altLocalRepoName", file("$altLocalRepoPath"))(Resolver.ivyStylePatterns) +// |} +// |""".stripMargin) +// } +// } + lazy val docProjects: ScopeFilter = ScopeFilter( inAnyProject -- inProjects(sbtRoot, sbtProj, scriptedSbtProj, scriptedPluginProj), inConfigurations(Compile) diff --git a/project/Scripted.scala b/project/Scripted.scala index a3e71a94f..a821ff446 100644 --- a/project/Scripted.scala +++ b/project/Scripted.scala @@ -25,10 +25,12 @@ trait ScriptedKeys { lazy val scriptedSource = SettingKey[File]("scripted-source") lazy val scriptedPrescripted = TaskKey[File => Unit]("scripted-prescripted") lazy val scriptedBufferLog = SettingKey[Boolean]("scripted-buffer-log") + lazy val scriptedLaunchOpts = SettingKey[Seq[String]]("scripted-launch-opts", "options to pass to jvm launching scripted tasks") } object Scripted { lazy val MavenResolverPluginTest = config("mavenResolverPluginTest") extend Compile + lazy val RepoOverrideTest = config("repoOverrideTest") extend Compile import sbt.complete._ import DefaultParsers._ @@ -83,14 +85,14 @@ object Scripted { launchOpts: Array[String], prescripted: java.util.List[File]): Unit } - def doScripted(launcher: File, scriptedSbtClasspath: Seq[Attributed[File]], scriptedSbtInstance: ScalaInstance, - sourcePath: File, bufferLog: Boolean, args: Seq[String], prescripted: File => Unit): Unit = { + def doScripted(launcher: File, scriptedSbtClasspath: Seq[Attributed[File]], + scriptedSbtInstance: ScalaInstance, sourcePath: File, bufferLog: Boolean, + args: Seq[String], prescripted: File => Unit, launchOpts: Seq[String]): Unit = { System.err.println(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}") val noJLine = new classpath.FilteredLoader(scriptedSbtInstance.loader, "jline." :: Nil) val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, noJLine) val bridgeClass = Class.forName("sbt.test.ScriptedRunner", true, loader) val bridge = bridgeClass.newInstance.asInstanceOf[SbtScriptedRunner] - val launcherVmOptions = Array("-XX:MaxPermSize=256M", "-Xmx1G") // increased after a failure in scripted source-dependencies/macro try { // Using java.util.List to encode File => Unit. val callback = new java.util.AbstractList[File] { @@ -101,7 +103,7 @@ object Scripted { def get(x: Int): sbt.File = ??? def size(): Int = 0 } - bridge.run(sourcePath, bufferLog, args.toArray, launcher, launcherVmOptions, callback) + bridge.run(sourcePath, bufferLog, args.toArray, launcher, launchOpts.toArray, callback) } catch { case ite: java.lang.reflect.InvocationTargetException => throw ite.getCause } } } diff --git a/sbt/src/repo-override-test/dependency-management/default-resolvers/build.sbt b/sbt/src/repo-override-test/dependency-management/default-resolvers/build.sbt new file mode 100644 index 000000000..7984b34c7 --- /dev/null +++ b/sbt/src/repo-override-test/dependency-management/default-resolvers/build.sbt @@ -0,0 +1,11 @@ +lazy val check = taskKey[Unit]("") + +lazy val root = (project in file(".")). + settings( + autoScalaLibrary := false, + check := { + val ar = appResolvers.value.get + assert(!(ar exists { _.name == "jcenter" })) + assert(!(ar exists { _.name == "public" })) + } + ) diff --git a/sbt/src/repo-override-test/dependency-management/default-resolvers/test b/sbt/src/repo-override-test/dependency-management/default-resolvers/test new file mode 100644 index 000000000..15675b169 --- /dev/null +++ b/sbt/src/repo-override-test/dependency-management/default-resolvers/test @@ -0,0 +1 @@ +> check diff --git a/sbt/src/repo-override-test/repo.config b/sbt/src/repo-override-test/repo.config new file mode 100644 index 000000000..f3301bb9f --- /dev/null +++ b/sbt/src/repo-override-test/repo.config @@ -0,0 +1,3 @@ +[repositories] + local + typesafe-ivy-releases: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]