=pro upgrade to latest sbt and add first auto plugins

* RootSettings plugin contains settings for root project
* other auto plugins that are meant only for root project depend on RootSettings
* other auto plugins that are meant for every project are enabled by default reducing boilerplate
This commit is contained in:
Martynas Mickevičius 2014-11-30 15:34:59 +02:00
parent 338f61886e
commit 22334da2a1
26 changed files with 117 additions and 101 deletions

View file

@ -53,17 +53,17 @@ For a Pull Request to be considered at all it has to meet these requirements:
3. The code must be well documented in the Typesafe's standard documentation format (see the Documentation section below). 3. The code must be well documented in the Typesafe's standard documentation format (see the Documentation section below).
4. The commit messages must properly describe the changes, see further below. 4. The commit messages must properly describe the changes, see further below.
5. All Typesafe projects must include Typesafe copyright notices. Each project can choose between one of two approaches: 5. All Typesafe projects must include Typesafe copyright notices. Each project can choose between one of two approaches:
1. All source files in the project must have a Typesafe copyright notice in the file header. 1. All source files in the project must have a Typesafe copyright notice in the file header.
2. The Notices file for the project includes the Typesafe copyright notice and no other files contain copyright notices. See http://www.apache.org/legal/src-headers.html for instructions for managing this approach for copyrights. 2. The Notices file for the project includes the Typesafe copyright notice and no other files contain copyright notices. See http://www.apache.org/legal/src-headers.html for instructions for managing this approach for copyrights.
Akka uses the first choice, having copyright notices in every file header. Akka uses the first choice, having copyright notices in every file header.
Other guidelines to follow for copyright notices: Other guidelines to follow for copyright notices:
- Use a form of ``Copyright (C) 2011-2013 Typesafe Inc. <http://www.typesafe.com>``, where the start year is when the project or file was first created and the end year is the last time the project or file was modified. - Use a form of ``Copyright (C) 2011-2013 Typesafe Inc. <http://www.typesafe.com>``, where the start year is when the project or file was first created and the end year is the last time the project or file was modified.
- Never delete or change existing copyright notices, just add additional info. - Never delete or change existing copyright notices, just add additional info.
- Do not use ``@author`` tags since it does not encourage [Collective Code Ownership](http://www.extremeprogramming.org/rules/collective.html). However, each project should make sure that the contributors gets the credit they deserve—in a text file or page on the project website and in the release notes etc. - Do not use ``@author`` tags since it does not encourage [Collective Code Ownership](http://www.extremeprogramming.org/rules/collective.html). However, each project should make sure that the contributors gets the credit they deserve—in a text file or page on the project website and in the release notes etc.
If these requirements are not met then the code should **not** be merged into master, or even reviewed - regardless of how good or important it is. No exceptions. If these requirements are not met then the code should **not** be merged into master, or even reviewed - regardless of how good or important it is. No exceptions.
@ -71,7 +71,7 @@ Whether or not a pull request (or parts of it) shall be back- or forward-ported
## Continuous Integration ## Continuous Integration
Each project should be configured to use a continuous integration (CI) tool (i.e. a build server à la Jenkins). Typesafe has a Jenkins server farm that can be used. The CI tool should, on each push to master, build the **full** distribution and run **all** tests, and if something fails it should email out a notification with the failure report to the committer and the core team. The CI tool should also be used in conjunction with Typesafes Pull Request Validator (discussed below). Each project should be configured to use a continuous integration (CI) tool (i.e. a build server à la Jenkins). Typesafe has a [Jenkins server farm](https://jenkins.akka.io/) that can be used. The CI tool should, on each push to master, build the **full** distribution and run **all** tests, and if something fails it should email out a notification with the failure report to the committer and the core team. The CI tool should also be used in conjunction with a Pull Request validator (discussed below).
## Documentation ## Documentation
@ -92,13 +92,13 @@ For larger projects that have invested a lot of time and resources into their cu
## External Dependencies ## External Dependencies
All the external runtime dependencies for the project, including transitive dependencies, must have an open source license that is equal to, or compatible with, [Apache 2](http://www.apache.org/licenses/LICENSE-2.0). All the external runtime dependencies for the project, including transitive dependencies, must have an open source license that is equal to, or compatible with, [Apache 2](http://www.apache.org/licenses/LICENSE-2.0).
This must be ensured by manually verifying the license for all the dependencies for the project: This must be ensured by manually verifying the license for all the dependencies for the project:
1. Whenever a committer to the project changes a version of a dependency (including Scala) in the build file. 1. Whenever a committer to the project changes a version of a dependency (including Scala) in the build file.
2. Whenever a committer to the project adds a new dependency. 2. Whenever a committer to the project adds a new dependency.
3. Whenever a new release is cut (public or private for a customer). 3. Whenever a new release is cut (public or private for a customer).
Which licenses are compatible with Apache 2 are defined in [this doc](http://www.apache.org/legal/3party.html#category-a), where you can see that the licenses that are listed under ``Category A`` automatically compatible with Apache 2, while the ones listed under ``Category B`` needs additional action: Which licenses are compatible with Apache 2 are defined in [this doc](http://www.apache.org/legal/3party.html#category-a), where you can see that the licenses that are listed under ``Category A`` automatically compatible with Apache 2, while the ones listed under ``Category B`` needs additional action:
@ -119,13 +119,13 @@ Follow these guidelines when creating public commits and writing commit messages
1. If your work spans multiple local commits (for example; if you do safe point commits while working in a feature branch or work in a branch for long time doing merges/rebases etc.) then please do not commit it all but rewrite the history by squashing the commits into a single big commit which you write a good commit message for (like discussed in the following sections). For more info read this article: [Git Workflow](http://sandofsky.com/blog/git-workflow.html). Every commit should be able to be used in isolation, cherry picked etc. 1. If your work spans multiple local commits (for example; if you do safe point commits while working in a feature branch or work in a branch for long time doing merges/rebases etc.) then please do not commit it all but rewrite the history by squashing the commits into a single big commit which you write a good commit message for (like discussed in the following sections). For more info read this article: [Git Workflow](http://sandofsky.com/blog/git-workflow.html). Every commit should be able to be used in isolation, cherry picked etc.
2. First line should be a descriptive sentence what the commit is doing. It should be possible to fully understand what the commit does—but not necessarily how it does it—by just reading this single line. We follow the “imperative present tense” style for commit messages ([more info here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)). 2. First line should be a descriptive sentence what the commit is doing. It should be possible to fully understand what the commit does—but not necessarily how it does it—by just reading this single line. We follow the “imperative present tense” style for commit messages ([more info here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)).
It is **not ok** to only list the ticket number, type "minor fix" or similar. In order to help with automatic filtering of the commit history (generating ChangeLogs, writing the migration guide, code archaeology) we use the following encoding: It is **not ok** to only list the ticket number, type "minor fix" or similar. In order to help with automatic filtering of the commit history (generating ChangeLogs, writing the migration guide, code archaeology) we use the following encoding:
* the first character is either '!' (for breaking API changes), '+' (for non-breaking API additions) or '=' (for API-neutral commits) * the first character is either '!' (for breaking API changes), '+' (for non-breaking API additions) or '=' (for API-neutral commits)
* then follows a comma-separated list of module abbreviations, formed by using the first three letters of the module name (the “akka-” prefix being stripped off), e.g. `act`, `clu`, `doc`; it is intentional that `akka-actor-tests` receives the same abbreviation as `akka-actor`. For commits modifying the project itself (sbt files or anything in `project/`) please use `pro`. * then follows a comma-separated list of module abbreviations, formed by using the first three letters of the module name (the “akka-” prefix being stripped off), e.g. `act`, `clu`, `doc`; it is intentional that `akka-actor-tests` receives the same abbreviation as `akka-actor`. For commits modifying the project itself (sbt files or anything in `project/`) please use `pro`.
* then follows a space character, a hash sign '#' and the ticket number * then follows a space character, a hash sign '#' and the ticket number
* the rest of the line (usually there are 64 characters left) makes up the textual summary * the rest of the line (usually there are 64 characters left) makes up the textual summary
If the commit is a small fix, then you are done. If not, go to 3. If the commit is a small fix, then you are done. If not, go to 3.
3. Following the single line description should be a blank line followed by an enumerated list with the details of the commit. 3. Following the single line description should be a blank line followed by an enumerated list with the details of the commit.
@ -143,8 +143,16 @@ Example:
## How To Enforce These Guidelines? ## How To Enforce These Guidelines?
### Make Use Of Typesafes Pull Request Validator ### Make Use of Pull Request Validator
It is recommended to set up the project to use Typesafes [Pull Request Validator](https://github.com/typesafehub/ghpullrequest-validator) that automatically merges the code, builds it, runs the tests and comments on the Pull Request in GitHub. Akka uses [Jenkins GitHub pull request builder plugin](https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin) that automatically merges the code, builds it, runs the tests and comments on the Pull Request in GitHub.
Upon a submission of a Pull Request the Github pull request builder plugin will post a following comment:
Can one of the repo owners verify this patch?
This requires a member from a core team to start Pull Request validation process by posting comment consisting only of `OK TO TEST`. From now on, whenever new commits are pushed to the Pull Request, a validation job will be automaticaly started and the results of the validation posted to the Pull Request.
A Pull Request validation job can be started manually by posting `TEST THIS PLEASE` comment on the Pull Request.
## Source style ## Source style

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -0,0 +1 @@
sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -0,0 +1 @@
sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

View file

@ -1 +1 @@
sbt.version=0.13.1 sbt.version=0.13.7

1
build.sbt Normal file
View file

@ -0,0 +1 @@
enablePlugins(akka.RootSettings)

View file

@ -40,11 +40,10 @@ object AkkaBuild extends Build {
lazy val root = Project( lazy val root = Project(
id = "akka", id = "akka",
base = file("."), base = file("."),
settings = parentSettings ++ Release.settings ++ unidocSettings ++ Publish.versionSettings ++ settings = parentSettings ++ Release.settings ++ unidocSettings ++
SphinxDoc.akkaSettings ++ Dist.settings ++ s3Settings ++ mimaSettings ++ scaladocSettings ++ SphinxDoc.akkaSettings ++ Dist.settings ++ s3Settings ++ mimaSettings ++ scaladocSettings ++
GraphiteBuildEvents.settings ++ Protobuf.settings ++ Unidoc.settings(Seq(samples), Seq(remoteTests)) ++ Seq( GraphiteBuildEvents.settings ++ Protobuf.settings ++ Unidoc.settings(Seq(samples), Seq(remoteTests)) ++ Seq(
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", "false").toBoolean, parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", "false").toBoolean,
Publish.defaultPublishTo in ThisBuild <<= crossTarget / "repository",
Dist.distExclude := Seq(actorTests.id, docs.id, samples.id, osgi.id), Dist.distExclude := Seq(actorTests.id, docs.id, samples.id, osgi.id),
S3.host in S3.upload := "downloads.typesafe.com.s3.amazonaws.com", S3.host in S3.upload := "downloads.typesafe.com.s3.amazonaws.com",
@ -231,7 +230,7 @@ object AkkaBuild extends Build {
) ++ ) ++
resolverSettings resolverSettings
lazy val baseSettings = Defaults.defaultSettings ++ Publish.settings lazy val baseSettings = Defaults.defaultSettings
lazy val parentSettings = baseSettings ++ Seq( lazy val parentSettings = baseSettings ++ Seq(
publishArtifact := false, publishArtifact := false,

View file

@ -1,99 +1,61 @@
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka package akka
import sbt._ import sbt._
import sbt.Keys._ import sbt.Keys._
import sbt.Project.Initialize
import java.io.File import java.io.File
object Publish { object Publish extends AutoPlugin {
final val Snapshot = "-SNAPSHOT"
val defaultPublishTo = SettingKey[File]("default-publish-to") val defaultPublishTo = settingKey[File]("Default publish directory")
lazy val settings = Seq( override def trigger = allRequirements
override lazy val projectSettings = Seq(
crossPaths := false, crossPaths := false,
pomExtra := akkaPomExtra, pomExtra := akkaPomExtra,
publishTo <<= akkaPublishTo, publishTo := akkaPublishTo.value,
credentials ++= akkaCredentials, credentials ++= akkaCredentials,
organizationName := "Typesafe Inc.", organizationName := "Typesafe Inc.",
organizationHomepage := Some(url("http://www.typesafe.com")), organizationHomepage := Some(url("http://www.typesafe.com")),
publishMavenStyle := true, publishMavenStyle := true,
// Maven central cannot allow other repos. pomIncludeRepository := { x => false },
// TODO - Make sure all artifacts are on central. defaultPublishTo := crossTarget.value / "repository"
pomIncludeRepository := { x => false }
)
lazy val versionSettings = Seq(
commands += stampVersion
) )
def akkaPomExtra = { def akkaPomExtra = {
(<inceptionYear>2009</inceptionYear> <inceptionYear>2009</inceptionYear>
<scm> <scm>
<url>git://github.com/akka/akka.git</url> <url>git://github.com/akka/akka.git</url>
<connection>scm:git:git@github.com:akka/akka.git</connection> <connection>scm:git:git@github.com:akka/akka.git</connection>
</scm>) ++ makeDevelopersXml(Map( </scm>
"jboner" -> "Jonas Boner",
"viktorklang" -> "Viktor Klang",
"rkuhn" -> "Roland Kuhn",
"pvlugter" -> "Peter Vlugter"
// TODO - More than the names in the last 10 commits
))
}
private[this] def makeDevelopersXml(users: Map[String,String]) =
<developers> <developers>
{ <developer>
for((id, user) <- users) <id>akka-contributors</id>
yield <developer><id>{id}</id><name>{user}</name></developer> <name>Akka Contributors</name>
} <email>akka-dev@googlegroups.com</email>
<url>https://github.com/akka/akka/graphs/contributors</url>
</developer>
</developers> </developers>
def sonatypePublishTo: Initialize[Option[Resolver]] = {
version { v: String =>
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
} }
def akkaPublishTo: Initialize[Option[Resolver]] = { private def akkaPublishTo = Def.setting {
(defaultPublishTo, version) { (defaultPT, v) => sonatypeRepo(version.value) orElse localRepo(defaultPublishTo.value)
akkaPublishRepository orElse
sonatypeRepo(v) orElse
Some(Resolver.file("Default Local Repository", defaultPT))
}
} }
def sonatypeRepo(version: String): Option[Resolver] = { private def sonatypeRepo(version: String): Option[Resolver] =
Option(sys.props("publish.maven.central")) filter (_.toLowerCase == "true") map { _ => Option(sys.props("publish.maven.central")) filter (_.toLowerCase == "true") map { _ =>
val nexus = "https://oss.sonatype.org/" val nexus = "https://oss.sonatype.org/"
if(version endsWith "-SNAPSHOT") ("snapshots" at nexus + "content/repositories/snapshots") if (version endsWith "-SNAPSHOT") "snapshots" at nexus + "content/repositories/snapshots"
else ("releases" at nexus + "service/local/staging/deploy/maven2") else "releases" at nexus + "service/local/staging/deploy/maven2"
} }
}
def akkaPublishRepository: Option[Resolver] = private def localRepo(repository: File) =
Option(System.getProperty("akka.publish.repository", null)) map { "Akka Publish Repository" at _ } Some(Resolver.file("Default Local Repository", repository))
def akkaCredentials: Seq[Credentials] = private def akkaCredentials: Seq[Credentials] =
Option(System.getProperty("akka.publish.credentials", null)) map (f => Credentials(new File(f))) toSeq Option(System.getProperty("akka.publish.credentials", null)).map(f => Credentials(new File(f))).toSeq
// timestamped versions
def stampVersion = Command.command("stamp-version") { state =>
val extracted = Project.extract(state)
extracted.append(List(version in ThisBuild ~= stamp), state)
}
def stamp(version: String): String = {
if (version endsWith Snapshot) (version stripSuffix Snapshot) + "-" + timestamp(System.currentTimeMillis)
else version
}
def timestamp(time: Long): String = {
val format = new java.text.SimpleDateFormat("yyyyMMdd-HHmmss")
format.format(new java.util.Date(time))
}
} }

View file

@ -0,0 +1,10 @@
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka
import sbt.AutoPlugin
object RootSettings extends AutoPlugin {
// settings for root project will go here
}

View file

@ -0,0 +1,34 @@
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka
import sbt._
import sbt.Keys._
object TimeStampede extends AutoPlugin {
override def requires = RootSettings
override def trigger = allRequirements
override lazy val projectSettings = Seq(
commands += stampVersion
)
final val Snapshot = "-SNAPSHOT"
def stampVersion = Command.command("stampVersion") { state =>
val extracted = Project.extract(state)
extracted.append(List(version in ThisBuild ~= stamp), state)
}
def stamp(version: String): String = {
if (version endsWith Snapshot) (version stripSuffix Snapshot) + "-" + timestamp(System.currentTimeMillis)
else version
}
def timestamp(time: Long): String = {
val format = new java.text.SimpleDateFormat("yyyyMMdd-HHmmss")
format.format(new java.util.Date(time))
}
}

View file

@ -1 +1 @@
sbt.version=0.13.5 sbt.version=0.13.7