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

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

This example Akka source code file (Release.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

akka, compile, release, seq, settingkey, sphinx

The Release.scala Akka example source code

package akka

import sbt._
import sbt.Keys._
import java.io.File
import com.typesafe.sbt.site.SphinxSupport.{ generate, Sphinx }
import com.typesafe.sbt.pgp.PgpKeys.publishSigned
import com.typesafe.sbt.S3Plugin.S3
import sbtunidoc.Plugin.UnidocKeys._

object Release {
  val releaseDirectory = SettingKey[File]("release-directory")

  lazy val settings: Seq[Setting[_]] = commandSettings ++ Seq(
    releaseDirectory <<= crossTarget / "release"
  )

  lazy val commandSettings = Seq(
    commands ++= Seq(buildReleaseCommand, uploadReleaseCommand)
  )

  def buildReleaseCommand = Command.command("build-release") { state =>
    val extracted = Project.extract(state)
    val release = extracted.get(releaseDirectory)
    val releaseVersion = extracted.get(version)
    val projectRef = extracted.get(thisProjectRef)
    val repo = extracted.get(Publish.defaultPublishTo)
    val state1 = extracted.runAggregated(publishSigned in projectRef, state)
    val (state2, Seq(api, japi)) = extracted.runTask(unidoc in Compile, state1)
    val (state3, docs) = extracted.runTask(generate in Sphinx, state2)
    val (state4, dist) = extracted.runTask(Dist.dist, state3)
    val (state5, activatorDist) = extracted.runTask(ActivatorDist.activatorDist in LocalProject(AkkaBuild.samples.id), state4)

    IO.delete(release)
    IO.createDirectory(release)
    IO.copyDirectory(repo, release / "releases")
    IO.copyDirectory(api, release / "api" / "akka" / releaseVersion)
    IO.copyDirectory(japi, release / "japi" / "akka" / releaseVersion)
    IO.copyDirectory(docs, release / "docs" / "akka" / releaseVersion)
    IO.copyFile(dist, release / "downloads" / dist.name)
    for (f <- (activatorDist * "*.zip").get)
      IO.copyFile(f, release / "downloads" / f.name)
    state5
  }

  def uploadReleaseCommand = Command.command("upload-release") { state =>
    val extracted = Project.extract(state)
    val (state1, _) = extracted.runTask(S3.upload, state)
    state1
  }
}

Other Akka source code examples

Here is a short list of links related to this Akka Release.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.