Skip to content

Commit

Permalink
Merge pull request #172 from sbt/wip/packageMapping-tests
Browse files Browse the repository at this point in the history
Wip/package mapping tests
  • Loading branch information
muuki88 committed Feb 22, 2014
2 parents 9790943 + 4a9708b commit cfe8ff8
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ trait LinuxPlugin extends Plugin {
*/
def packageTemplateMapping(files: String*)(dir: File = new File(sys.props("java.io.tmpdir"))) = LinuxPackageMapping(files map ((dir, _)))

// TODO can the packager.MappingsHelper be used here?
/**
* @see #mapDirectoryAndContents
* @param dirs - directories to map
Expand Down
31 changes: 31 additions & 0 deletions src/sbt-test/debian/test-mapping-helpers/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import NativePackagerKeys._
import NativePackagerHelper._

packagerSettings

mapGenericFilesToLinux

name := "debian-test"

version := "0.1.0"

maintainer := "Josh Suereth <[email protected]>"

packageSummary := "Test debian package"

packageDescription := """A fun package description of our software,
with multiple lines."""


// linuxPackageMappings in Debian += packageTemplateMapping("/var/run/debian") // not work
// linuxPackageMappings in Debian += packageTemplateMapping("/var/run/debian")() // not work
linuxPackageMappings in Debian += packageTemplateMapping(Seq("/opt/test/other"):_*)()

linuxPackageMappings in Debian <+= (Keys.normalizedName, target) map { (name, tmp) =>
packageTemplateMapping("/opt/test/" + name)(tmp)
}

// Consider using mappings in Universal
linuxPackageMappings in Debian += packageDirectoryAndContentsMapping(
(baseDirectory.value / "src" / "resources" / "conf") -> "/usr/share/conf"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
12 changes: 12 additions & 0 deletions src/sbt-test/debian/test-mapping-helpers/src/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

sbt (0.12.0-build-0100)

* No need for different launcher jar files now

-- Joshua Suereth <[email protected]> 2012-07-2012

sbt (0.11.2-build-0100)

* First debian package release

-- Joshua Suereth <[email protected]> 2011-11-29
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.\" Process this file with
.\" groff -man -Tascii sbt.1
.\"
.TH TEST 1 "NOVEMBER 2013" Linux "User Manuals"
.SH NAME
test \- TEST
Empty file.
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions src/sbt-test/debian/test-mapping-helpers/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Run the debian packaging.
> debian:package-bin
$ exists target/debian-test-0.1.0.deb

# Template directories
$ exists target/debian-test-0.1.0/opt/test/debian-test
$ exists target/debian-test-0.1.0/opt/test/other

# Directories with content
$ exists target/debian-test-0.1.0/usr/share/conf
$ exists target/debian-test-0.1.0/usr/share/conf/application.conf
$ exists target/debian-test-0.1.0/usr/share/conf/log4j.properties
28 changes: 28 additions & 0 deletions src/sbt-test/universal/test-mapping-helpers/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import NativePackagerKeys._
import com.typesafe.sbt.packager.MappingsHelper._

packagerSettings

packagerSettings

name := "simple-test"

version := "0.1.0"

// or just place your cache folder in /src/universal/
mappings in Universal ++= directory("src/main/resources/cache")

// or just place your cache folder in /src/universal/
mappings in Universal ++= contentOf("src/main/resources/docs")

mappings in Universal <+= (packageBin in Compile, sourceDirectory ) map { (_, src) =>
// we are using the reference.conf as default application.conf
// the user can override settings here
val conf = src / "main" / "resources" / "reference.conf"
conf -> "conf/application.conf"
}

TaskKey[Unit]("unzip") <<= (packageBin in Universal, streams) map { (zipFile, streams) =>
val args = Seq(zipFile.getAbsolutePath)
Process("unzip", args) ! streams.log
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README content
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions src/sbt-test/universal/test-mapping-helpers/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Run the universal packaging.
> universal:package-bin
$ exists target/universal/simple-test-0.1.0.zip

> unzip
$ exists simple-test-0.1.0/

# Mapped by convention
$ exists simple-test-0.1.0/conf/
$ exists simple-test-0.1.0/conf/log4j.properties

# Mapped with directory()
$ exists simple-test-0.1.0/cache/
$ exists simple-test-0.1.0/cache/cache.conf

# Mapped with contentOf()
$ exists simple-test-0.1.0/
$ exists simple-test-0.1.0/README

# Mapped with task
$ exists simple-test-0.1.0/conf/application.conf
$ absent simple-test-0.1.0/conf/reference.conf

0 comments on commit cfe8ff8

Please sign in to comment.