diff --git a/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala index 5262a59ee..d4714e100 100644 --- a/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/universal/UniversalPlugin.scala @@ -3,6 +3,7 @@ package packager package universal import sbt._ +import sbt.Keys.cacheDirectory import Keys._ import Archives._ import sbt.Keys.TaskStreams @@ -36,7 +37,7 @@ trait UniversalPlugin extends Plugin { mappings <<= sourceDirectory map findSources, dist <<= (packageBin, streams) map printDist, stagingDirectory <<= target apply (_ / "stage"), - stage <<= (stagingDirectory, mappings) map stageFiles + stage <<= (cacheDirectory, stagingDirectory, mappings) map stageFiles(config.name) )) ++ Seq( sourceDirectory in config <<= sourceDirectory apply (_ / config.name), target in config <<= target apply (_ / config.name) @@ -54,9 +55,12 @@ trait UniversalPlugin extends Plugin { dist } - private[this] def stageFiles(to: File, mappings: Seq[(File, String)]): Unit = { - val copies = mappings collect { case (f, p) => f -> (to / p) } - IO.copy(copies) + private[this] def stageFiles(config: String)(cacheDirectory: File, to: File, mappings: Seq[(File, String)]): Unit = { + val cache = cacheDirectory / ("packager-mappings-" + config) + val copies = mappings map { + case (file, path) => file -> (to / path) + } + Sync(cache)(copies) // Now set scripts to executable using Java's lack of understanding of permissions. // TODO - Config file user-readable permissions.... for { diff --git a/src/sbt-test/universal/clear-stage-dir/build.sbt b/src/sbt-test/universal/clear-stage-dir/build.sbt new file mode 100644 index 000000000..8c687dea6 --- /dev/null +++ b/src/sbt-test/universal/clear-stage-dir/build.sbt @@ -0,0 +1,7 @@ +import NativePackagerKeys._ + +packagerSettings + +name := "simple-test" + +version := "0.1.0" diff --git a/src/sbt-test/universal/clear-stage-dir/project/plugins.sbt b/src/sbt-test/universal/clear-stage-dir/project/plugins.sbt new file mode 100644 index 000000000..b53de154c --- /dev/null +++ b/src/sbt-test/universal/clear-stage-dir/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) diff --git a/src/sbt-test/universal/clear-stage-dir/src/universal/conf/test b/src/sbt-test/universal/clear-stage-dir/src/universal/conf/test new file mode 100644 index 000000000..ab1006ffd --- /dev/null +++ b/src/sbt-test/universal/clear-stage-dir/src/universal/conf/test @@ -0,0 +1 @@ +# Test configuration to include in zips. diff --git a/src/sbt-test/universal/clear-stage-dir/src/universal/conf/test2 b/src/sbt-test/universal/clear-stage-dir/src/universal/conf/test2 new file mode 100644 index 000000000..c181ac4a0 --- /dev/null +++ b/src/sbt-test/universal/clear-stage-dir/src/universal/conf/test2 @@ -0,0 +1 @@ +# removable file \ No newline at end of file diff --git a/src/sbt-test/universal/clear-stage-dir/test b/src/sbt-test/universal/clear-stage-dir/test new file mode 100644 index 000000000..d6e088c0b --- /dev/null +++ b/src/sbt-test/universal/clear-stage-dir/test @@ -0,0 +1,9 @@ +# Stage the distribution and ensure files show up. +> universal:stage +$ exists target/universal/stage/conf/test +$ exists target/universal/stage/conf/test2 +$ delete src/universal/conf/test2 +> universal:stage +$ exists target/universal/stage/conf/test +$ absent target/universal/stage/conf/test2 +