From 47aed79b07726430dc421c2de90dee08e2d189c9 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Thu, 8 Apr 2010 20:14:51 -0400 Subject: [PATCH 1/3] Add description to update-plugins and add 'builder' help message. --- sbt/src/main/scala/sbt/BuilderProject.scala | 9 ++++++++- sbt/src/main/scala/sbt/Main.scala | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sbt/src/main/scala/sbt/BuilderProject.scala b/sbt/src/main/scala/sbt/BuilderProject.scala index 820360c4f..c8de1a806 100644 --- a/sbt/src/main/scala/sbt/BuilderProject.scala +++ b/sbt/src/main/scala/sbt/BuilderProject.scala @@ -153,8 +153,15 @@ final class BuilderProject(val info: ProjectInfo, val pluginPath: Path, rawLogge lazy val extract = pluginTask(extractSources()) dependsOn(autoUpdate) lazy val autoUpdate = pluginTask(loadAndUpdate(false)) dependsOn(compile) // manual update. force uptodate = false - lazy val update = task { setUptodate(false); loadAndUpdate(true) } dependsOn(compile) + lazy val update = task { manualUpdate() } dependsOn(compile) describedAs("Manual plugin update. Used when autoUpdate is disabled.") + def manualUpdate() = + { + setUptodate(false) + val result = loadAndUpdate(true) + logInfo("'reload' required to rebuild plugins.") + result + } def doSync() = pluginCompileConditional.run orElse { setUptodate(true); None } def extractSources() = { diff --git a/sbt/src/main/scala/sbt/Main.scala b/sbt/src/main/scala/sbt/Main.scala index 813189cdf..ca094d6b2 100755 --- a/sbt/src/main/scala/sbt/Main.scala +++ b/sbt/src/main/scala/sbt/Main.scala @@ -454,6 +454,7 @@ class xMain extends xsbti.AppMain printCmd(SetAction + " ", "Sets the value of the property given as its argument.") printCmd(GetAction + " ", "Gets the value of the property given as its argument.") printCmd(ProjectConsoleAction, "Enters the Scala interpreter with the current project definition bound to the variable 'current' and all members imported.") + printCmd(BuilderCommand, "Set the current project to be the project definition builder.") if(!isInteractive) printCmd(InteractiveCommand, "Enters the sbt interactive shell") } From a5bb434d2a8cba2cd22718caac970cfbb23a2a4c Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 20 Apr 2010 08:41:11 -0400 Subject: [PATCH 2/3] Minor documentation addition --- sbt/src/main/scala/sbt/ProjectInfo.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbt/src/main/scala/sbt/ProjectInfo.scala b/sbt/src/main/scala/sbt/ProjectInfo.scala index beb071478..f2c889dbf 100644 --- a/sbt/src/main/scala/sbt/ProjectInfo.scala +++ b/sbt/src/main/scala/sbt/ProjectInfo.scala @@ -36,7 +36,8 @@ final case class ProjectInfo(projectDirectory: File, dependencies: Iterable[Proj val builderPath = projectPath / ProjectInfo.MetadataDirectoryName /** The boot directory contains the jars needed for building the project, including Scala, sbt, processors and dependencies of these.*/ def bootPath = builderPath / Project.BootDirectoryName - /** The path to the build definition project. */ + /** The path to the build definition project. + * Currently, this is 'project/build'. */ def builderProjectPath = builderPath / Project.BuilderProjectDirectoryName def builderProjectOutputPath = builderProjectPath / Project.DefaultOutputDirectoryName /** The path to the plugin definition project. This declares the plugins to use for the build definition.*/ From 092a42cf53b01c2976fce69099683cde9f2f42fa Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 20 Apr 2010 08:41:32 -0400 Subject: [PATCH 3/3] Test for extra properties files --- .../changes/first.properties | 1 + .../changes/second.properties | 2 ++ .../project/build.properties | 2 ++ .../project/build/Test.scala | 29 +++++++++++++++++++ .../sbt-test/project/extra-environment/test | 26 +++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 sbt/src/sbt-test/project/extra-environment/changes/first.properties create mode 100644 sbt/src/sbt-test/project/extra-environment/changes/second.properties create mode 100644 sbt/src/sbt-test/project/extra-environment/project/build.properties create mode 100644 sbt/src/sbt-test/project/extra-environment/project/build/Test.scala create mode 100644 sbt/src/sbt-test/project/extra-environment/test diff --git a/sbt/src/sbt-test/project/extra-environment/changes/first.properties b/sbt/src/sbt-test/project/extra-environment/changes/first.properties new file mode 100644 index 000000000..865c9991f --- /dev/null +++ b/sbt/src/sbt-test/project/extra-environment/changes/first.properties @@ -0,0 +1 @@ +first.property=set-first \ No newline at end of file diff --git a/sbt/src/sbt-test/project/extra-environment/changes/second.properties b/sbt/src/sbt-test/project/extra-environment/changes/second.properties new file mode 100644 index 000000000..116151c6c --- /dev/null +++ b/sbt/src/sbt-test/project/extra-environment/changes/second.properties @@ -0,0 +1,2 @@ +first.property=set-first +second.property=set-second \ No newline at end of file diff --git a/sbt/src/sbt-test/project/extra-environment/project/build.properties b/sbt/src/sbt-test/project/extra-environment/project/build.properties new file mode 100644 index 000000000..0a2f48ee6 --- /dev/null +++ b/sbt/src/sbt-test/project/extra-environment/project/build.properties @@ -0,0 +1,2 @@ +project.name=test-env +project.version=1.0 \ No newline at end of file diff --git a/sbt/src/sbt-test/project/extra-environment/project/build/Test.scala b/sbt/src/sbt-test/project/extra-environment/project/build/Test.scala new file mode 100644 index 000000000..e812012f4 --- /dev/null +++ b/sbt/src/sbt-test/project/extra-environment/project/build/Test.scala @@ -0,0 +1,29 @@ +import sbt._ + +class Test(info: ProjectInfo) extends DefaultProject(info) +{ + lazy val FirstDefault = "a" + lazy val SecondDefault = "b" + lazy val FirstSet = "set-first" + lazy val SecondSet = "set-second" + + lazy val extra = new BasicEnvironment + { + def log = Test.this.log + def envBackingPath = info.builderPath / "extra.properties" + + lazy val firstProperty = propertyOptional[String](FirstDefault) + lazy val secondProperty = propertyOptional[String](SecondDefault) + } + + import extra.{firstProperty, secondProperty} + + lazy val checkFirstUnset = checkTask(firstProperty, FirstDefault, "first.property") + lazy val checkFirstSet = checkTask(firstProperty, FirstSet, "first.property") + lazy val checkSecondUnset = checkTask(secondProperty, SecondDefault, "second.property") + lazy val checkSecondSet = checkTask(secondProperty, SecondSet, "second.property") + + def checkTask[T](property: extra.Property[T], expected: T, name: String): Task = + task { if(property.value == expected) None else Some("Expected "+name+" to be '" + expected + "', was: " + property.value) } + +} \ No newline at end of file diff --git a/sbt/src/sbt-test/project/extra-environment/test b/sbt/src/sbt-test/project/extra-environment/test new file mode 100644 index 000000000..813a92031 --- /dev/null +++ b/sbt/src/sbt-test/project/extra-environment/test @@ -0,0 +1,26 @@ +# check that both properties are unset + +> check-first-unset +->check-first-set +> check-second-unset +->check-second-set + +# create the extra properties file with only the first property set + +$ copy-file changes/first.properties project/extra.properties +> reload + +-> check-first-unset +>check-first-set +> check-second-unset +->check-second-set + +# create the extra properties file with both properties set + +$ copy-file changes/second.properties project/extra.properties +> reload + +-> check-first-unset +>check-first-set +-> check-second-unset +>check-second-set \ No newline at end of file