diff options
author | Diego <diegolparra@gmail.com> | 2016-12-04 15:37:51 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2016-12-04 15:37:51 -0300 |
commit | 56039ef037d42cb817d0bc6d5a5891bc87e633c3 (patch) | |
tree | 711d36b49d69f7321ea75172d9d4969e318d7afe /project | |
parent | e02d137ab960676cb89ff597bc33915f8b83a4d2 (diff) | |
download | Kamon-56039ef037d42cb817d0bc6d5a5891bc87e633c3.tar.gz Kamon-56039ef037d42cb817d0bc6d5a5891bc87e633c3.tar.bz2 Kamon-56039ef037d42cb817d0bc6d5a5891bc87e633c3.zip |
wip
Diffstat (limited to 'project')
-rw-r--r-- | project/Dependencies.scala | 46 | ||||
-rw-r--r-- | project/Publish.scala | 50 | ||||
-rw-r--r-- | project/Release.scala | 80 | ||||
-rw-r--r-- | project/Settings.scala | 70 | ||||
-rw-r--r-- | project/VersionWithSHA.scala | 28 | ||||
-rw-r--r-- | project/build.properties | 1 | ||||
-rw-r--r-- | project/plugins.sbt | 16 |
7 files changed, 291 insertions, 0 deletions
diff --git a/project/Dependencies.scala b/project/Dependencies.scala new file mode 100644 index 00000000..bcc926f5 --- /dev/null +++ b/project/Dependencies.scala @@ -0,0 +1,46 @@ +/* ========================================================================================= + * Copyright © 2013-2016 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +import sbt._ + +object Dependencies { + + val resolutionRepos = Seq( + "typesafe repo" at "http://repo.typesafe.com/typesafe/releases/", + "Kamon Repository Snapshots" at "http://snapshots.kamon.io" + ) + + val akkaVersion = "2.4.12" + val slf4jVersion = "1.7.7" + + val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % akkaVersion + val akkaTestKit = "com.typesafe.akka" %% "akka-testkit" % akkaVersion + val akkaActor = "com.typesafe.akka" %% "akka-actor" % akkaVersion + + val aspectJ = "org.aspectj" % "aspectjweaver" % "1.8.9" + val hdrHistogram = "org.hdrhistogram" % "HdrHistogram" % "2.1.9" + + val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion + val slf4jnop = "org.slf4j" % "slf4j-nop" % slf4jVersion + + val logback = "ch.qos.logback" % "logback-classic" % "1.0.13" + + val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" + + def compileScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile") + def testScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "test") + def providedScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "provided") + def optionalScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile,optional") +} diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 00000000..ddb64d2d --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,50 @@ +/* ========================================================================================= + * Copyright © 2013-2014 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +import sbt._ +import sbt.Keys._ + +object Publish { + + lazy val settings = Seq( + crossPaths := true, + pomExtra := kamonPomExtra, + publishTo := kamonRepo, + organization := "io.kamon", + pomIncludeRepository := { x => false }, + publishMavenStyle := true, + publishArtifact in Test := false + ) + + def kamonRepo = Some(Resolver.sftp("Kamon Snapshots Repository", "snapshots.kamon.io", "/var/local/snapshots-repo")) + + def kamonPomExtra = { + <url>http://kamon.io</url> + <licenses> + <license> + <name>Apache 2</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + </license> + </licenses> + <scm> + <url>git://github.com/kamon-io/Kamon.git</url> + <connection>scm:git:git@github.com:kamon-io/Kamon.git</connection> + </scm> + <developers> + <developer><id>ivantopo</id><name>Ivan Topolnjak</name><url>https://twitter.com/ivantopo</url></developer> + <developer><id>dpsoft</id><name>Diego Parra</name><url>https://twitter.com/diegolparra</url></developer> + </developers> + } +} diff --git a/project/Release.scala b/project/Release.scala new file mode 100644 index 00000000..a388a66f --- /dev/null +++ b/project/Release.scala @@ -0,0 +1,80 @@ +/* ========================================================================================= + * Copyright © 2013-2014 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +import com.typesafe.sbt.pgp._ +import sbt._ +import sbt.Keys._ +import sbtrelease.ReleasePlugin._ +import sbtrelease.ReleaseStateTransformations._ +import sbtrelease.ReleaseStep +import sbtrelease.Utilities._ +import xerial.sbt.Sonatype._ + +object Release { + + def settings = Seq.empty ++ + releaseSettings ++ + Seq( + ReleaseKeys.releaseProcess := Seq[ReleaseStep]( + checkSnapshotDependencies, + inquireVersions, + runClean, + runTest, + setReleaseVersion, + commitReleaseVersion, // .copy(check = identity), // FIX 0: to skip "all changes committed" precondition + tagRelease, + publishSignedArtifacts, // FIX 1: publish signed. Otherwise sonatype won't sync artifact to maven central + setNextVersion, + commitNextVersion, + pushChanges, + refreshVersionWithSHA // FIX 2: update "version" by replacing the "-SNAPSHOT" with "-WHATEVER_COMMIT_SHA" + ) + ) ++ + sonatypeSettings ++ + Seq( + // sbt-sonatype overrides publishTo. So we need to restore kamon repo declaration for snapshots + publishTo := { if (isSnapshot.value) Publish.kamonRepo else publishTo.value } + ) + + + def kamonSonatypeCredentials = + Credentials.toDirect(Credentials(Path.userHome / ".ivy2" / "kamon-credentials-sonatype.properties")) + + /** + * Hijacked from [[sbtrelease.ReleaseStateTransformations.publishArtifacts]] + */ + lazy val publishSignedArtifacts = ReleaseStep( + action = { st: State => + val extracted = st.extract + val ref = extracted.get(thisProjectRef) + extracted.runAggregated(PgpKeys.publishSigned in Global in ref, st) + }, + check = st => { + // getPublishTo fails if no publish repository is set up. + val ex = st.extract + val ref = ex.get(thisProjectRef) + Classpaths.getPublishTo(ex.get(publishTo in Global in ref)) + st + }, + enableCrossBuild = true + ) + + lazy val refreshVersionWithSHA = ReleaseStep(st => { + reapply(Seq( + version in ThisBuild := VersionWithSHA.kamonVersionWithSHA(st.extract.get(version)) + ), st) + }) + +}
\ No newline at end of file diff --git a/project/Settings.scala b/project/Settings.scala new file mode 100644 index 00000000..d33b8a99 --- /dev/null +++ b/project/Settings.scala @@ -0,0 +1,70 @@ +/* ========================================================================================= + * Copyright © 2013-2016 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +import sbt._ +import Keys._ +import com.typesafe.sbt.SbtScalariform +import com.typesafe.sbt.SbtScalariform.ScalariformKeys +import Publish.{settings => publishSettings} +import Release.{settings => releaseSettings} +import scalariform.formatter.preferences._ + +object Settings { + + val JavaVersion = "1.6" + val SVersion = "2.11.8" + + lazy val basicSettings = Seq( + scalaVersion := SVersion, + crossScalaVersions := Seq("2.10.5", SVersion, "2.12.0"), + resolvers ++= Dependencies.resolutionRepos, + fork in run := true, + parallelExecution in Global := false, + scalacOptions := commonScalacOptions, + javacOptions := commonJavaOptions + ) ++ publishSettings ++ releaseSettings + + lazy val commonJavaOptions = Seq( + "-Xlint:-options", + "-source", JavaVersion, "-target", JavaVersion) + + lazy val commonScalacOptions = Seq( + "-encoding", + "utf8", + "-g:vars", + "-feature", + "-unchecked", + "-deprecation", + "-language:postfixOps", + "-language:implicitConversions", + "-Xlog-reflective-calls" +// "-Yno-adapted-args", +// "-Ywarn-dead-code", +// "-Ywarn-numeric-widen", +// "-Ywarn-value-discard", + ) + + lazy val formatSettings = SbtScalariform.scalariformSettings ++ Seq( + ScalariformKeys.preferences in Compile := formattingPreferences, + ScalariformKeys.preferences in Test := formattingPreferences + ) + + def formattingPreferences = + FormattingPreferences() + .setPreference(RewriteArrowSymbols, true) + .setPreference(AlignParameters, false) + .setPreference(AlignSingleLineCaseStatements, true) + .setPreference(DoubleIndentClassDeclaration, true) +} diff --git a/project/VersionWithSHA.scala b/project/VersionWithSHA.scala new file mode 100644 index 00000000..58139f7f --- /dev/null +++ b/project/VersionWithSHA.scala @@ -0,0 +1,28 @@ +/* ========================================================================================= + * Copyright © 2013-2016 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= + */ + +import sbt.Process + +object VersionWithSHA { + + private lazy val VersionWithShaRegex = """(?:\d+\.)?(?:\d+\.)?(?:\d+)-[0-9a-f]{5,40}""" + + /** Don't use this. You should use version.value instead. */ + def kamonVersionWithSHA(version: String) = version.takeWhile(_ != '-') + "-" + Process("git rev-parse HEAD").lines.head + + /** Don't use this. You should use isSnapshot.value instead. */ + def kamonIsSnapshot(version: String) = (version matches VersionWithShaRegex) || (version endsWith "-SNAPSHOT") + +}
\ No newline at end of file diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 00000000..5f32afe7 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=0.13.13
\ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 00000000..ee51c0a9 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,16 @@ +resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/" + +resolvers += "Kamon Releases" at "http://repo.kamon.io" + +addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.10.6") + +addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.2") + +addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0") + +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1") + +addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1") + +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.1") + |