From 5e611b35a891ab35d15a5eb8fcb8fcee6de1bb08 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Wed, 6 May 2015 10:51:29 +0200 Subject: refactor build --- project/Build.scala | 74 ++++++++++++++++++++++++++++++++ project/Dependencies.scala | 7 --- project/FlowBuild.scala | 101 -------------------------------------------- project/Publish.scala | 32 ++++++++++++++ project/build.properties | 2 +- project/uniqueVersion.scala | 21 --------- 6 files changed, 107 insertions(+), 130 deletions(-) create mode 100644 project/Build.scala delete mode 100644 project/Dependencies.scala delete mode 100644 project/FlowBuild.scala create mode 100644 project/Publish.scala delete mode 100644 project/uniqueVersion.scala (limited to 'project') diff --git a/project/Build.scala b/project/Build.scala new file mode 100644 index 0000000..f0266f3 --- /dev/null +++ b/project/Build.scala @@ -0,0 +1,74 @@ +import sbt._ +import Keys._ +import JniKeys._ +import NativeKeys._ +import Publish._ + + +object FlowBuild extends Build { + + lazy val commonSettings: Seq[Setting[_]] = Seq( + version := "2.1.1", + scalaVersion in ThisBuild := "2.11.6", + crossScalaVersions in ThisBuild := Seq("2.10.5", "2.11.6"), + organization := "com.github.jodersky", + resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/", + scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature") + ) + + lazy val runSettings: Seq[Setting[_]] = Seq( + fork := true, + connectInput in run := true, + outputStrategy := Some(StdoutOutput) + ) + + lazy val root: Project = ( + Project("root", file(".")) + aggregate(main, native) + settings(publishSettings: _*) + settings( + publishArtifact := false, + publishTo := Some(Resolver.file("Unused transient repository", target.value / "unusedrepo")) // make sbt-pgp happy + ) + ) + + lazy val main: Project = ( + Project("main", file("flow-main")) + settings(commonSettings: _*) + settings(publishSettings: _*) + settings(JniDefaults.settings: _*) + settings( + name := "flow", + javahHeaderDirectory := (baseDirectory in ThisBuild).value / "flow-native" / "src", + javahClasses := Seq("com.github.jodersky.flow.internal.NativeSerial"), + compileOrder in Compile := CompileOrder.Mixed, + libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.10" + ) + ) + + lazy val native: Project = ( + Project("native", file("flow-native-sbt")) + settings(commonSettings: _*) + settings(publishSettings: _*) + settings(NativeDefaults.settings: _*) + settings( + name := "flow-native", + crossPaths := false, + nativeBuildDirectory := (baseDirectory in ThisBuild).value / "flow-native" + ) + ) + + lazy val samplesTerminal = ( + Project("samples-terminal", file("flow-samples") / "terminal") + settings(commonSettings: _*) + settings(runSettings: _*) + dependsOn(main) + + //kind of dirty, but it gets the sample to run without installing native libraries + settings( + (run in Compile) <<= (run in Compile).dependsOn(nativeBuild in native), + javaOptions += "-Djava.library.path=" + (nativeOutputDirectory in native).value.getAbsolutePath() + ) + ) + +} diff --git a/project/Dependencies.scala b/project/Dependencies.scala deleted file mode 100644 index 6e4c328..0000000 --- a/project/Dependencies.scala +++ /dev/null @@ -1,7 +0,0 @@ -import sbt._ - -object Dependencies { - - lazy val akkaActor = "com.typesafe.akka" %% "akka-actor" % "2.3.9" - -} diff --git a/project/FlowBuild.scala b/project/FlowBuild.scala deleted file mode 100644 index 3c1e8f5..0000000 --- a/project/FlowBuild.scala +++ /dev/null @@ -1,101 +0,0 @@ -import sbt._ -import Keys._ -import JniKeys._ -import UniqueVersionKeys._ -import NativeKeys._ - - -object FlowBuild extends Build { - val Organization = "com.github.jodersky" - val ScalaVersion = "2.11.5" - val Version = "2.1.0" - - - lazy val commonSettings: Seq[Setting[_]] = - UniqueVersionDefaults.settings ++ - Seq( - organization := Organization, - scalaVersion in ThisBuild := ScalaVersion, - crossScalaVersions in ThisBuild := Seq("2.10.4", ScalaVersion), - baseVersion := Version, - licenses := Seq(("BSD-3-Clause", url("http://opensource.org/licenses/BSD-3-Clause"))), - homepage := Some(url("http://github.com/jodersky/flow")), - resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/", - scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature")) - - lazy val publishSettings: Seq[Setting[_]] = Seq( - publishMavenStyle := true, - publishTo := { - val nexus = "https://oss.sonatype.org/" - if (isSnapshot.value) - Some("snapshots" at nexus + "content/repositories/snapshots") - else - Some("releases" at nexus + "service/local/staging/deploy/maven2") - }, - pomIncludeRepository := { _ => false }, - pomExtra := { - - git@github.com:jodersky/flow.git - scm:git:git@github.com:jodersky/flow.git - - - - jodersky - Jakob Odersky - - - } - ) - - lazy val runSettings: Seq[Setting[_]] = Seq( - fork := true, - connectInput in run := true, - outputStrategy := Some(StdoutOutput) - ) - - lazy val root: Project = ( - Project("root", file(".")).aggregate(flow, flowNative) - settings( - publish := (), - publishLocal := () - ) - ) - - lazy val flow: Project = ( - Project("flow", file("flow")) - settings(commonSettings: _*) - settings(publishSettings: _*) - settings(JniDefaults.settings: _*) - settings( - javahHeaderDirectory := (baseDirectory in ThisBuild).value / "flow-native" / "src", - javahClasses := Seq("com.github.jodersky.flow.internal.NativeSerial"), - compileOrder in Compile := CompileOrder.Mixed, - libraryDependencies += Dependencies.akkaActor - ) - ) - - lazy val flowNative: Project = ( - Project("flow-native", file("flow-native-sbt")) - settings(commonSettings: _*) - settings(publishSettings: _*) - settings(NativeDefaults.settings: _*) - settings( - crossPaths := false, - nativeBuildDirectory := (baseDirectory in ThisBuild).value / "flow-native" - ) - ) - - lazy val samplesTerminal = ( - Project("flow-samples-terminal", file("flow-samples") / "terminal") - settings(commonSettings: _*) - settings(runSettings: _*) - dependsOn(flow) - - //kind of dirty, but it gets the sample to run without installing native libraries - settings( - (run in Compile) <<= (run in Compile).dependsOn(nativeBuild in flowNative), - javaOptions += "-Djava.library.path=" + (nativeOutputDirectory in flowNative).value.getAbsolutePath() - ) - ) - -} diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 0000000..fa22a75 --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,32 @@ +import sbt._ +import Keys._ + +object Publish { + + lazy val publishSettings: Seq[Setting[_]] = Seq( + licenses := Seq(("BSD-3-Clause", url("http://opensource.org/licenses/BSD-3-Clause"))), + homepage := Some(url("http://github.com/jodersky/flow")), + publishMavenStyle := true, + publishTo := { + val nexus = "https://oss.sonatype.org/" + if (isSnapshot.value) + Some("snapshots" at nexus + "content/repositories/snapshots") + else + Some("releases" at nexus + "service/local/staging/deploy/maven2") + }, + pomIncludeRepository := { _ => false }, + pomExtra := { + + git@github.com:jodersky/flow.git + scm:git:git@github.com:jodersky/flow.git + + + + jodersky + Jakob Odersky + + + } + ) + +} diff --git a/project/build.properties b/project/build.properties index 748703f..a6e117b 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.7 +sbt.version=0.13.8 diff --git a/project/uniqueVersion.scala b/project/uniqueVersion.scala deleted file mode 100644 index 1a7860f..0000000 --- a/project/uniqueVersion.scala +++ /dev/null @@ -1,21 +0,0 @@ -import sbt._ -import Keys._ - -object UniqueVersionKeys { - - val gitHeadCommitSha = settingKey[String]("Current commit sha.") - val baseVersion = settingKey[String]("Base part of version, string without unique hash appended.") - val isRelease = settingKey[Boolean]("Is this a release? Should the unique hash be appended to the version string?") - -} - -object UniqueVersionDefaults { - import UniqueVersionKeys._ - - lazy val settings: Seq[Setting[_]] = Seq( - gitHeadCommitSha := Process("git rev-parse HEAD").lines.head, - isRelease := sys.props("release") == "true", - version := { if (isRelease.value) baseVersion.value else baseVersion.value + "-" + gitHeadCommitSha.value } - ) - -} \ No newline at end of file -- cgit v1.2.3