Skip to content
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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Note: The plugin does not work on WindowsOS
Add the following to your `project/plugins.sbt` file:

```scala
addSbtPlugin("com.github.hochgi" % "sbt-cassandra" % "1.0.4")
addSbtPlugin("com.tuplejump.com.github.hochgi" % "sbt-cassandra" % "1.1.0")
```

## Usage ##
### Basic: ###
In `build.sbt`, enable the plugin for desired project and specify the version of cassandra against which tests are to be run,
In `build.sbt`, enable the plugin for desired project and specify the version of cassandra against which tests are to be run,

```scala
lazy val root = (project in file("."))
Expand Down Expand Up @@ -49,6 +49,10 @@ the plugin downloads cassandra tar from [Apache Cassandra Archives](http://archi
```scala
cassandraTgz := "resources/custom-cassandra.tgz"
```
to prevent downloading cassandra tar file if the file already exists. Parameter is ignored if custom file is specified in `cassandraTgz`
```scala
forceCassandraDownload := false
```
to override cassandra configuration, e.g:
```scala
configMappings += "auto_snapshot" -> true
Expand All @@ -70,9 +74,8 @@ The `configMappings` setting should be used to change host, port and cqlPort. Th
* host - `listen_address`
* port - `rpc_port`
* cqlPort - `native_transport_port`

to pass java args to cassandra,
```scala
cassandraJavaArgs := Seq("-Xmx1G")
```

8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
sbtPlugin := true

organization := "com.github.hochgi"
organization := "com.tuplejump.com.github.hochgi"

name := "sbt-cassandra"

description := "SBT plugin to launch and use Cassandra during integration tests"

version := "1.0.4"
version := "1.1.0"

scalaVersion := "2.10.6"

Expand Down Expand Up @@ -38,8 +38,8 @@ licenses := Seq("The MIT License (MIT)" -> url("http://opensource.org/licenses/M

pomExtra := (
<scm>
<url>https://github.com/hochgi/sbt-cassandra-plugin.git</url>
<connection>scm:[email protected]:hochgi/sbt-cassandra-plugin.git</connection>
<url>https://github.com/tuplejump/sbt-cassandra-plugin.git</url>
<connection>scm:[email protected]:tuplejump/sbt-cassandra-plugin.git</connection>
</scm>
<developers>
<developer>
Expand Down
2 changes: 1 addition & 1 deletion demo/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logLevel := Level.Warn

addSbtPlugin("com.github.hochgi" % "sbt-cassandra" % "1.0.4")
addSbtPlugin("com.tuplejump.com.github.hochgi" % "sbt-cassandra" % "1.1.0")
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,25 @@ object CassandraITPlugin extends AutoPlugin {
lazy val cassandraJavaArgs = SettingKey[Seq[String]]("cassandra-java-args",
"Optional. Java arguments to be passed to Cassandra")

lazy val forceCassandraDownload = SettingKey[Boolean]("force-cassandra-download",
"Optional. Defaults to true")
}

private val PIDFileName = "cass.pid"

def deployCassandra(tarFile: String,
casVersion: String,
targetDir: File,
logger: Logger): File = {
logger: Logger,
forceCassandraDownload: Boolean): File = {
val cassandraTarGz: File = if (tarFile.nonEmpty) {
file(tarFile)
} else if (casVersion.nonEmpty) {
val file: File = new File(targetDir, s"apache-cassandra-$casVersion-bin.tar.gz")
val source = s"http://archive.apache.org/dist/cassandra/$casVersion/apache-cassandra-$casVersion-bin.tar.gz"
IO.download(url(source), file)
if (!file.exists || forceCassandraDownload) {
val source = s"http://archive.apache.org/dist/cassandra/$casVersion/apache-cassandra-$casVersion-bin.tar.gz"
IO.download(url(source), file)
}
file
} else {
sys.error("Specify Cassandra version or path to Cassandra tar.gz file")
Expand Down Expand Up @@ -199,7 +204,8 @@ object CassandraITPlugin extends AutoPlugin {
cleanCassandraAfterStop := true,
cassandraStartDeadline := 20,
configMappings := Nil,
cassandraJavaArgs := Nil
cassandraJavaArgs := Nil,
forceCassandraDownload := true
)

override def projectSettings: Seq[_root_.sbt.Def.Setting[_]] = super.projectSettings ++
Expand All @@ -211,7 +217,7 @@ object CassandraITPlugin extends AutoPlugin {
val logger = streams.value.log

val cassHome = deployCassandra(cassandraTgz.value.trim,
cassandraVersion.value.trim, targetDir, logger)
cassandraVersion.value.trim, targetDir, logger, forceCassandraDownload.value)

val confDir: String = {
if (cassandraConfigDir.value.trim.isEmpty) {
Expand Down