alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Akka/Scala example source code file (ActivatorDist.scala)

This example Akka source code file (ActivatorDist.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Akka and Scala source code examples by using tags.

All credit for the original source code belongs to akka.io; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Akka tags/keywords

activatordist, akka, create, initialize, nil, pathfinder, seq, settingkey, taskkey

The ActivatorDist.scala Akka example source code

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
      }
    }
  }

}

Other Akka source code examples

Here is a short list of links related to this Akka ActivatorDist.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.