2013-12-04 12:12:38 +01:00
|
|
|
package akka
|
|
|
|
|
|
|
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
import sbt.classpath.ClasspathUtilities
|
|
|
|
|
import sbt.Project.Initialize
|
|
|
|
|
import java.io.File
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
)
|
|
|
|
|
|
2013-12-15 17:43:46 +01:00
|
|
|
def aggregatedProjects(projectRef: ProjectRef, structure: Load.BuildStructure, exclude: Set[String]): Seq[ProjectRef] = {
|
2013-12-04 12:12:38 +01:00
|
|
|
val aggregate = Project.getProject(projectRef, structure).toSeq.flatMap(_.aggregate)
|
|
|
|
|
aggregate flatMap { ref =>
|
2013-12-15 17:43:46 +01:00
|
|
|
if (exclude contains ref.project) Seq.empty
|
|
|
|
|
else ref +: aggregatedProjects(ref, structure, exclude)
|
2013-12-04 12:12:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def activatorDistTask: Initialize[Task[File]] = {
|
|
|
|
|
(thisProjectRef, baseDirectory, activatorDistDirectory, version, buildStructure, streams) map {
|
|
|
|
|
(project, projectBase, activatorDistDirectory, version, structure, s) => {
|
2013-12-15 17:43:46 +01:00
|
|
|
val exclude = Set("akka-sample-osgi-dining-hakkers", "akka-sample-osgi-dining-hakkers-api",
|
|
|
|
|
"akka-sample-osgi-dining-hakkers-command", "akka-sample-osgi-dining-hakkers-core",
|
|
|
|
|
"akka-sample-osgi-dining-hakkers-uncommons", "akka-sample-osgi-dining-hakkers-integration")
|
|
|
|
|
val allProjects = aggregatedProjects(project, structure, exclude).flatMap(p => Project.getProject(p, structure))
|
2013-12-04 12:12:38 +01:00
|
|
|
val rootGitignoreLines = IO.readLines(AkkaBuild.akka.base / ".gitignore")
|
|
|
|
|
for (p <- allProjects) {
|
|
|
|
|
val localGitignoreLines = if ((p.base / ".gitignore").exists) IO.readLines(p.base / ".gitignore") else Nil
|
|
|
|
|
val gitignorePathFinder = (".gitignore" :: localGitignoreLines ::: rootGitignoreLines).foldLeft(PathFinder.empty)(
|
|
|
|
|
(acc, x) => acc +++ (p.base * x))
|
|
|
|
|
val filteredPathFinder = (p.base * "*") --- gitignorePathFinder
|
|
|
|
|
for (f <- filteredPathFinder.get) {
|
|
|
|
|
val target = activatorDistDirectory / p.id / f.name
|
|
|
|
|
println("copy: " + target)
|
|
|
|
|
IO.copyDirectory(f, target, overwrite = true, preserveLastModified = true)
|
|
|
|
|
}
|
|
|
|
|
Dist.zip(activatorDistDirectory / p.id, activatorDistDirectory / (p.id + "-" + version + ".zip"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activatorDistDirectory
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|