-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from ivanfrain/issue-161
Attempt to resolve issue 161 - Add human readable methods to map directories
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/scala/com/typesafe/sbt/packager/MappingsHelper.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.typesafe.sbt | ||
package packager | ||
|
||
import sbt._ | ||
|
||
/** A set of helper methods to simplify the writing of mappings */ | ||
object MappingsHelper { | ||
|
||
/** return a Seq of mappings which effect is to add a whole directory in the generated package */ | ||
def directory(sourceDir: File): Seq[(File, String)] = { | ||
val parentFile = sourceDir.getParentFile | ||
if (parentFile != null) | ||
sourceDir.*** pair relativeTo(sourceDir.getParentFile) | ||
else | ||
sourceDir.*** pair basic | ||
} | ||
|
||
/** It lightens the build file if one wants to give a string instead of file. */ | ||
def directory(sourceDir: String): Seq[(File, String)] = { | ||
directory(file(sourceDir)) | ||
} | ||
|
||
/** return a Seq of mappings which effect is to add the content of directory in the generated package, | ||
* excluding the directory itself */ | ||
def contentOf(sourceDir: File): Seq[(File, String)] = { | ||
(sourceDir.*** --- sourceDir) pair relativeTo(sourceDir) | ||
} | ||
|
||
/** It lightens the build file if one wants to give a string instead of file. */ | ||
def contentOf(sourceDir: String): Seq[(File, String)] = { | ||
contentOf(file(sourceDir)) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters