Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScalaJS artifact #97

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target
.classpath
.project
.settings
.cache-*
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,31 @@ The execution model leverages on Applicative Functors to express the independenc

# Getting started #

To use clump, just add the dependency to the project's build configuration. There are two versions of the project:
To use clump, just add the dependency to the project's build configuration. There are three versions of the project:

1. `clump-scala`, that uses Scala Futures and doesn't have external dependencies.
2. `clump-twitter`, that uses Twitter Futures and has the dependency to `twitter-util`.
1. `clump-scalaJVM`, that uses Scala Futures and doesn't have external dependencies.
2. `clump-scalaJS`, for usage with ScalaJS.
3. `clump-twitter`, that uses Twitter Futures and has the dependency to `twitter-util`.

__Important__: Change ```x.x.x``` with the latest version listed by the [CHANGELOG.md](https://github.com/getclump/clump/blob/master/CHANGELOG.md) file.

SBT

clump-scalaJVM
```scala
libraryDependencies ++= Seq(
"io.getclump" %% "clump-scala" % "x.x.x"
)
```

clump-scalaJS
```scala
libraryDependencies ++= Seq(
"io.getclump" %%% "clump-scala" % "x.x.x"
)
```

clump-twitter
```scala
libraryDependencies ++= Seq(
"io.getclump" %% "clump-twitter" % "x.x.x"
Expand Down
58 changes: 35 additions & 23 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import com.typesafe.sbt.pgp.PgpKeys
import sbt.Keys._
import sbt._
import sbtrelease.ReleasePlugin._
import org.scalajs.sbtplugin.cross.CrossProject
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._

object Build extends Build {
val commonSettings = Seq(
organization := "io.getclump",
scalaVersion := "2.10.4",
crossScalaVersions := Seq("2.10.4", "2.11.5"),
libraryDependencies ++= Seq(
"org.specs2" %% "specs2" % "2.4.2" % "test",
"org.mockito" % "mockito-core" % "1.9.5" % "test"
),
scalaVersion := "2.11.6",
crossScalaVersions := Seq("2.10.4", "2.11.6"),
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.3.1",
testFrameworks += new TestFramework("utest.runner.Framework"),
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
Expand Down Expand Up @@ -58,22 +58,34 @@ object Build extends Build {
</developers>
)

lazy val clumpScala = Project(id = "clump-scala", base = file("."))
.settings(name := "clump-scala")
.settings(commonSettings: _*)
.settings(target <<= target(_ / "clump-scala"))
.aggregate(clumpTwitter)
lazy val clump =
Project(id = "clump", base = file("."))
.settings(scalaSource in Test := file("root"))
.settings(scalaSource in Compile := file("root"))
.settings(publish := { })
.aggregate(clumpScalaJs, clumpScalaJvm, clumpTwitter)

lazy val clumpTwitter = Project(id = "clump-twitter", base = file("."))
.settings(name := "clump-twitter")
.settings(commonSettings: _*)
.settings(libraryDependencies += "com.twitter" %% "util-core" % "6.22.0")
.settings(target <<= target(_ / "clump-twitter"))
.settings(excludeFilter in unmanagedSources := "package.scala")
.settings(sourceGenerators in Compile += Def.task {
val source = sourceDirectory.value / "main" / "scala" / "io" / "getclump" / "package-twitter.scala.tmpl"
val file = sourceManaged.value / "main" / "scala" / "io" / "getclump" / "package.scala"
IO.copyFile(source, file)
Seq(file)
}.taskValue)

lazy val clumpScala: CrossProject =
CrossProject(id = "clump-scala", base = file("."), CrossType.Pure)
.settings(name := "clump-scala")
.settings(commonSettings: _*)
.settings(target <<= target(_ / "clump-scala"))

lazy val clumpScalaJvm = clumpScala.jvm.aggregate(clumpScalaJs)
lazy val clumpScalaJs = clumpScala.js

lazy val clumpTwitter =
Project(id = "clump-twitter", base = file("."))
.settings(name := "clump-twitter")
.settings(commonSettings: _*)
.settings(libraryDependencies += "com.twitter" %% "util-core" % "6.22.0")
.settings(target <<= target(_ / "clump-twitter"))
.settings(excludeFilter in unmanagedSources := "package.scala")
.settings(sourceGenerators in Compile += Def.task {
val source = sourceDirectory.value / "main" / "scala" / "io" / "getclump" / "package-twitter.scala.tmpl"
val file = sourceManaged.value / "main" / "scala" / "io" / "getclump" / "package.scala"
IO.copyFile(source, file)
Seq(file)
}.taskValue)
}
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.5")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.3")
2 changes: 0 additions & 2 deletions src/main/scala/io/getclump/package-twitter.scala.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ package object getclump {
def sequence[T](futures: Seq[Future[T]]) = Future.collect(futures)
}

private[getclump] def awaitResult[T](future: Future[T]) =
com.twitter.util.Await.result(future)
}
2 changes: 0 additions & 2 deletions src/main/scala/io/getclump/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ package object getclump {
private[getclump]type Future[+T] = scala.concurrent.Future[T]
private[getclump] val Future = scala.concurrent.Future

private[getclump] def awaitResult[T](future: Future[T]) =
scala.concurrent.Await.result(future, scala.concurrent.duration.Duration.Inf)
}
Loading