forked from akka/akka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivatorDist.scala
45 lines (38 loc) · 1.87 KB
/
ActivatorDist.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package akka
import sbt._
import sbt.Keys._
import sbt.Def.Initialize
import java.io.File
import sbt.Task
object ActivatorDist {
val activatorDistDirectory = SettingKey[File]("activator-dist-directory")
val activatorDist = TaskKey[File]("activator-dist", "Create a zipped distribution of each activator sample.")
lazy val settings: Seq[Setting[_]] = Seq(
activatorDistDirectory <<= crossTarget / "activator-dist",
activatorDist <<= activatorDistTask
)
def activatorDistTask: Initialize[Task[File]] = {
(thisProjectRef, baseDirectory, activatorDistDirectory, version, buildStructure, streams) map {
(project, projectBase, activatorDistDirectory, version, structure, s) => {
val directories = projectBase.listFiles(DirectoryFilter).filter(dir => (dir / "activator.properties").exists)
val rootGitignoreLines = IO.readLines(AkkaBuild.root.base / ".gitignore")
for (dir <- directories) {
val localGitignoreLines = if ((dir / ".gitignore").exists) IO.readLines(dir / ".gitignore") else Nil
val gitignoreFileFilter = (".gitignore" :: localGitignoreLines ::: rootGitignoreLines).
foldLeft[FileFilter](NothingFilter)((acc, x) => acc || x)
val filteredPathFinder = PathFinder(dir) descendantsExcept("*", gitignoreFileFilter) filter(_.isFile)
filteredPathFinder pair Path.rebase(dir, activatorDistDirectory / dir.name) map {
case (source, target) =>
s.log.info(s"copying: $source -> $target")
IO.copyFile(source, target, preserveLastModified = true)
}
val targetDir = activatorDistDirectory / dir.name
val targetFile = activatorDistDirectory / (dir.name + "-" + version + ".zip")
s.log.info(s"zipping: $targetDir -> $targetFile")
Dist.zip(targetDir, targetFile)
}
activatorDistDirectory
}
}
}
}