Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip/package mapping tests #172

Merged
merged 5 commits into from
Feb 22, 2014
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
file("src/resources/conf") -> "/usr/share/conf"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note, you should always do this relative to a directory, like (baseDirectory.value / "src/resources/conf") -> "/usr/share/conf"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I'll change this

)
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.
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) map { (zipFile) =>
val args = Seq(zipFile.getAbsolutePath)
Process("unzip", args) !
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should always have the . here if you're using postfix or add the logs argument:

Process("unzip", args) ! streams.log

I realize sometimes I'm lazy here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh! I saw that one time and was a bit confused at first, but the get it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOH, that should be streams.value.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"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README content
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