From d970ab3af37c167c3a744bf71860ae862ae8f1d0 Mon Sep 17 00:00:00 2001 From: Dan Sanduleac Date: Mon, 19 May 2014 18:29:23 +0100 Subject: [PATCH] Re-add scripted test --- .../project/global-plugin/changes/Build.scala | 21 +++++++++++++++++++ .../global-plugin/changes/global-plugins.sbt | 3 +++ .../project/global-plugin/changes/plugins.sbt | 2 ++ sbt/src/sbt-test/project/global-plugin/test | 20 +++++++++++++++--- 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 sbt/src/sbt-test/project/global-plugin/changes/Build.scala create mode 100644 sbt/src/sbt-test/project/global-plugin/changes/global-plugins.sbt create mode 100644 sbt/src/sbt-test/project/global-plugin/changes/plugins.sbt diff --git a/sbt/src/sbt-test/project/global-plugin/changes/Build.scala b/sbt/src/sbt-test/project/global-plugin/changes/Build.scala new file mode 100644 index 000000000..2e1d49e2f --- /dev/null +++ b/sbt/src/sbt-test/project/global-plugin/changes/Build.scala @@ -0,0 +1,21 @@ +import sbt._ +import sbt.Keys._ + +object MyBuild extends Build { + lazy val mySettings = Defaults.defaultSettings ++ Seq( + name := "my-test-proj", + organization := "com.example", + check <<= update map checkVersion, + version := "0.1.0-SNAPSHOT") + + lazy val proj = Project("my-test-proj", file("."), settings = mySettings) + + lazy val check = taskKey[Unit]("Verifies that the junit dependency has the newer version (4.8)") + + def checkVersion(report: UpdateReport) { + for(mod <- report.allModules) { + if(mod.name == "junit") assert(mod.revision == "4.8", s"JUnit version (${mod.revision}) does not have the correct version") + } + } +} + diff --git a/sbt/src/sbt-test/project/global-plugin/changes/global-plugins.sbt b/sbt/src/sbt-test/project/global-plugin/changes/global-plugins.sbt new file mode 100644 index 000000000..2214d0397 --- /dev/null +++ b/sbt/src/sbt-test/project/global-plugin/changes/global-plugins.sbt @@ -0,0 +1,3 @@ +// use a small java library instead of a plugin to avoid incompatibilities when upgrading +// This version should be overridden by the one in the project. +libraryDependencies += "junit" % "junit" % "4.5" diff --git a/sbt/src/sbt-test/project/global-plugin/changes/plugins.sbt b/sbt/src/sbt-test/project/global-plugin/changes/plugins.sbt new file mode 100644 index 000000000..8c116930a --- /dev/null +++ b/sbt/src/sbt-test/project/global-plugin/changes/plugins.sbt @@ -0,0 +1,2 @@ +// the version should override the one from the global plugin +libraryDependencies += "junit" % "junit" % "4.8" diff --git a/sbt/src/sbt-test/project/global-plugin/test b/sbt/src/sbt-test/project/global-plugin/test index a100beb21..f5ab8b106 100644 --- a/sbt/src/sbt-test/project/global-plugin/test +++ b/sbt/src/sbt-test/project/global-plugin/test @@ -1,4 +1,18 @@ -# tests that a source file in $sbt.global.base/plugins/ is available to the build definition in project/ +$ copy-file changes/Build.scala project/Build.scala +> reload -# dummy to ensure project gets loaded -> name +# ensure that a new global dependency gets picked up +$ copy-file changes/global-plugins.sbt global/plugins/plugins.sbt +> reload + +# check that the class can be loaded +> eval Class.forName("org.junit.Test") + +# check that it is on the classpath +> eval (x => ()) : (org.junit.Test => Unit) + +# ensure that the global plugin version is overridden by the local version +# (because it's older) +$ copy-file changes/plugins.sbt project/plugins.sbt +> reload +> check