MappingsHelper

com.typesafe.sbt.packager.MappingsHelper
object MappingsHelper extends Mapper

A set of helper methods to simplify the writing of mappings

Attributes

Graph
Supertypes
class Mapper
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited types

type FileMap = File => Option[File]

Attributes

Inherited from:
Mapper
type PathMap = File => Option[String]

Attributes

Inherited from:
Mapper

Value members

Concrete methods

def contentOf(sourceDir: String): Seq[(File, String)]

It lightens the build file if one wants to give a string instead of file.

It lightens the build file if one wants to give a string instead of file.

Value parameters

sourceDir

as string representation

Attributes

Returns

mappings

Example
mappings in Universal ++= contentOf("extra")
def contentOf(sourceDir: File, conv0: FileConverter): Seq[(FileRef, String)]
def directory(sourceDir: String): Seq[(File, String)]

It lightens the build file if one wants to give a string instead of file.

It lightens the build file if one wants to give a string instead of file.

Attributes

Returns

mappings

Example
mappings in Universal ++= directory("extra")
def fromClasspath(entries: Seq[Attributed[FileRef]], target: String): Seq[(FileRef, String)]

Create mappings from your classpath. For example if you want to add additional dependencies, like test or model.

Create mappings from your classpath. For example if you want to add additional dependencies, like test or model.

Attributes

Returns

a list of mappings

Example

Add all test artifacts to a separated test folder

mappings in Universal ++= fromClasspath((managedClasspath in Test).value, target = "test")
def fromClasspath(entries: Seq[Attributed[FileRef]], target: String, includeArtifact: IncludeArtifact, includeOnNoArtifact: Boolean): Seq[(FileRef, String)]

Create mappings from your classpath. For example if you want to add additional dependencies, like test or model. You can also filter the artifacts that should be mapped to mappings.

Create mappings from your classpath. For example if you want to add additional dependencies, like test or model. You can also filter the artifacts that should be mapped to mappings.

Value parameters

entries

from where mappings should be created from

includeArtifact

function to determine if an artifact should result in a mapping

includeOnNoArtifact

default is false. When there's no Artifact meta data remove it

target

folder, e.g. model. Must not end with a slash

Attributes

Example

Filter all osgi bundles

mappings in Universal ++= fromClasspath(
  (managedClasspath in Runtime).value,
  "osgi",
  artifact => artifact.`type` == "bundle"
)
def relative(files: Seq[File], dirs: Seq[File], conv0: FileConverter): Seq[(FileRef, String)]

Get the mappings for the given files relative to the given directories.

Get the mappings for the given files relative to the given directories.

Attributes

Inherited methods

def abs: FileMap

Pairs a File with the absolute File obtained by calling getAbsoluteFile. Note that this usually means that relative files are resolved against the current working directory.

Pairs a File with the absolute File obtained by calling getAbsoluteFile. Note that this usually means that relative files are resolved against the current working directory.

Attributes

Inherited from:
Mapper
def allSubpaths(base: File): Iterable[(File, String)]

Selects all descendants of base directory and maps them to a path relative to base. base itself is not included.

Selects all descendants of base directory and maps them to a path relative to base. base itself is not included.

Attributes

Inherited from:
Mapper
def contentOf(baseDirectory: File): Seq[(File, String)]

return a Seq of mappings excluding the directory itself.

return a Seq of mappings excluding the directory itself.

Value parameters

baseDirectory

The directory that should be turned into a mappings sequence.

Attributes

Returns

mappings - The basicDirectory's contents exlcuding basicDirectory itself

Example

In order to create mappings for a static directory "extra" add

mappings ++= contentOf(baseDirectory.value / "extra")

The resulting mappings sequence will look something like this

File(baseDirectory/extras/file1) -> "file1"
File(baseDirectory/extras/file2) -> "file2"
...

Add a static directory "extra" and re-map the destination to a different path

mappings ++= contentOf(baseDirectory.value / "extra").map {
 case (src, destination) => src -> s"new/path/destination"
}
Inherited from:
Mapper
def directory(baseDirectory: File): Seq[(File, String)]

return a Seq of mappings which effect is to add a whole directory in the generated package

return a Seq of mappings which effect is to add a whole directory in the generated package

Value parameters

baseDirectory

The directory that should be turned into a mappings sequence.

Attributes

Returns

mappings The baseDirectory and all of its contents

Example

In order to create mappings for a static directory "extra" add

mappings ++= directory(baseDirectory.value / "extra")

The resulting mappings sequence will look something like this

File(baseDirectory/extras) -> "extras"
File(baseDirectory/extras/file1) -> "extras/file1"
File(baseDirectory/extras/file2) -> "extras/file2"
...
Inherited from:
Mapper
def fail: Any => Nothing

A mapper that throws an exception for any input. This is useful as the last mapper in a pipeline to ensure every input gets mapped.

A mapper that throws an exception for any input. This is useful as the last mapper in a pipeline to ensure every input gets mapped.

Attributes

Inherited from:
Mapper
def flat(newDirectory: File): FileMap

Constructs a FileMap that pairs a file with a file with the same name in newDirectory. For example, if newDirectory is /a/b, then /r/s/t/d.txt will be paired with /a/b/d.txt

Constructs a FileMap that pairs a file with a file with the same name in newDirectory. For example, if newDirectory is /a/b, then /r/s/t/d.txt will be paired with /a/b/d.txt

Attributes

Inherited from:
Mapper
def flatRebase(newBase: String): PathMap

A path mapper that pairs a File with a path constructed from newBase and the file's name. For example, if newBase = /new/a/, then /old/x/z.txt gets paired with /new/a/z.txt.

A path mapper that pairs a File with a path constructed from newBase and the file's name. For example, if newBase = /new/a/, then /old/x/z.txt gets paired with /new/a/z.txt.

Attributes

Inherited from:
Mapper
def normalizeBase(base: String): String

Attributes

Inherited from:
Mapper
def rebase(oldBase: File, newBase: File): FileMap

Produces a File mapper that pairs a descendant of oldBase with a file in newBase that preserving the relative path of the original file against oldBase. For example, if oldBase is /old/x/ and newBase is /new/a/, /old/x/y/z.txt gets paired with /new/a/y/z.txt.

Produces a File mapper that pairs a descendant of oldBase with a file in newBase that preserving the relative path of the original file against oldBase. For example, if oldBase is /old/x/ and newBase is /new/a/, /old/x/y/z.txt gets paired with /new/a/y/z.txt.

Attributes

Inherited from:
Mapper
def rebase(oldBases: Iterable[File], newBase: File, zero: FileMap): FileMap

Attributes

Inherited from:
Mapper
def rebase(oldBase: File, newBase: String): PathMap

A path mapper that pairs a descendent of oldBase with newBase prepended to the path relative to oldBase. For example, if oldBase = /old/x/ and newBase = new/a/, then /old/x/y/z.txt gets paired with new/a/y/z.txt.

A path mapper that pairs a descendent of oldBase with newBase prepended to the path relative to oldBase. For example, if oldBase = /old/x/ and newBase = new/a/, then /old/x/y/z.txt gets paired with new/a/y/z.txt.

Attributes

Inherited from:
Mapper
def relativeTo(bases: Iterable[File], zero: PathMap): PathMap

Attributes

Inherited from:
Mapper
def relativeTo(base: File): PathMap

A path mapper that pairs a File with its path relative to base. If the File is not a descendant of base, it is not handled (None is returned by the mapper).

A path mapper that pairs a File with its path relative to base. If the File is not a descendant of base, it is not handled (None is returned by the mapper).

Attributes

Inherited from:
Mapper
def resolve(newDirectory: File): FileMap

Returns a FileMap that resolves a relative File against newDirectory and pairs the original File with the resolved File. The mapper ignores absolute files.

Returns a FileMap that resolves a relative File against newDirectory and pairs the original File with the resolved File. The mapper ignores absolute files.

Attributes

Inherited from:
Mapper
def selectSubpaths(base: File, filter: FileFilter): Iterable[(File, String)]

Selects descendants of base directory matching filter and maps them to a path relative to base. base itself is not included.

Selects descendants of base directory matching filter and maps them to a path relative to base. base itself is not included.

Attributes

Inherited from:
Mapper
def total[A, B](f: A => B): A => Some[B]

A mapper that is defined on all inputs by the function f.

A mapper that is defined on all inputs by the function f.

Attributes

Inherited from:
Mapper
def transparent: Any => Option[Nothing]

A mapper that ignores all inputs.

A mapper that ignores all inputs.

Attributes

Inherited from:
Mapper

Inherited fields

val basic: PathMap

A path mapper that pairs a File with the path returned by calling getPath on it.

A path mapper that pairs a File with the path returned by calling getPath on it.

Attributes

Inherited from:
Mapper
val flat: PathMap

A path mapper that pairs a File with its name. For example, /x/y/z.txt gets paired with z.txt.

A path mapper that pairs a File with its name. For example, /x/y/z.txt gets paired with z.txt.

Attributes

Inherited from:
Mapper