Skip to content

Commit

Permalink
Merge pull request #15 from Shiti/develop
Browse files Browse the repository at this point in the history
DB-50
  • Loading branch information
helena committed Apr 4, 2016
2 parents 6f8eb26 + 65b6405 commit f8b91f9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
68 changes: 32 additions & 36 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "kafka-connect-cassandra"

version := "0.0.5"
version := "0.0.6"

crossScalaVersions := Seq("2.11.7", "2.10.6")

Expand All @@ -10,6 +10,8 @@ scalaVersion := sys.props.getOrElse("scala.version", crossScalaVersions.value.he

organization := "com.tuplejump"

organizationHomepage := Some(new java.net.URL("http://www.tuplejump.com"))

description := "A Kafka Connect Cassandra Source and Sink connector."

licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
Expand Down Expand Up @@ -37,35 +39,7 @@ libraryDependencies ++= Seq(
}
)

import com.github.hochgi.sbt.cassandra._

CassandraPlugin.cassandraSettings

cassandraVersion := cassandra
cassandraStartDeadline := 40
cassandraCqlInit := "src/it/resources/setup.cql"


test in IntegrationTest <<= (test in IntegrationTest).dependsOn(startCassandra)
testOnly in IntegrationTest <<= (testOnly in IntegrationTest).dependsOn(startCassandra)

//sbt-cassandra plugin adds these to Test configuration but not to IntegrationTest config
// https://github.com/hochgi/sbt-cassandra-plugin/issues/5
//if compilation of test classes fails, cassandra should not be invoked. (moreover, Test.Cleanup won't execute to stop it...)
startCassandra <<= startCassandra.dependsOn(compile in IntegrationTest)
//make sure to Stop cassandra when tests are done.
testOptions in IntegrationTest <+= (cassandraPid, stopCassandraAfterTests, cleanCassandraAfterStop, target) map {
case (pid, stop, clean, targetDir) => Tests.Cleanup(() => {
if(stop) stopCassandraMethod(clean, targetDir / "data", pid)
})
}

/* TODO
Found intransitive dependency (org.apache.cassandra:apache-cassandra:3.0.0) while publishMavenStyle is true,
but Maven repositories do not support intransitive dependencies. Use exclusions instead so transitive dependencies
will be correctly excluded in dependent projects.
*/
publishMavenStyle := false
publishMavenStyle := true

/* Compiler settings and checks, code checks and compliance: */
cancelable in Global := true
Expand Down Expand Up @@ -120,7 +94,7 @@ lazy val testOptionsSettings = Tests.Argument(TestFrameworks.ScalaTest, "-oDF")
lazy val testConfigSettings = inConfig(Test)(Defaults.testTasks) ++
inConfig(IntegrationTest)(Defaults.itSettings)

lazy val testSettings = testConfigSettings ++ cassandraSettings ++ Seq(
lazy val testSettings = testConfigSettings ++ Seq(
fork in IntegrationTest := false,
fork in Test := true,
parallelExecution in IntegrationTest := false,
Expand Down Expand Up @@ -156,12 +130,34 @@ pomExtra :=
</developer>
</developers>

lazy val root = (project in file(".")).settings(
publishTo <<= 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")
}

publishArtifact in Test := false

pomIncludeRepository := {
_ => false
}

pomIncludeRepository := { _ => false }

lazy val root = (project in file("."))
.enablePlugins(BuildInfoPlugin)
.enablePlugins(AutomateHeaderPlugin)
.enablePlugins(CassandraITPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](version),
buildInfoPackage := "com.tuplejump.kafka.connect.cassandra",
buildInfoObject := "CassandraConnectorInfo")
buildInfoObject := "CassandraConnectorInfo",
cassandraVersion := cassandra,
cassandraCqlInit := "src/it/resources/setup.cql",
cassandraStartDeadline := 40
)
.settings(testSettings)
.enablePlugins(BuildInfoPlugin)
.enablePlugins(AutomateHeaderPlugin)
.configs(IntegrationTest)

2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resolvers += "Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"

addSbtPlugin("com.github.hochgi" % "sbt-cassandra-plugin" % "0.6.2")
addSbtPlugin("com.tuplejump.com.github.hochgi" % "sbt-cassandra" % "1.0.0")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.5.0")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import scala.util.control.NonFatal
import org.apache.kafka.connect.connector.Task
import org.apache.kafka.common.config.ConfigException
import com.datastax.driver.core.Session
import org.apache.kafka.connect.errors.ConnectException

/** INTERNAL API. */
private[kafka] trait ConnectorLike extends Logging {
Expand Down Expand Up @@ -72,8 +73,9 @@ private[kafka] trait TaskLifecycle extends Task with ConnectorLike {

protected var _session: Option[Session] = None

private[cassandra] def session: Session = _session.getOrElse(throw new IllegalStateException(
"Sink has not been started yet or is not configured properly to connect to a cluster."))
private[cassandra] def session: Session = _session.getOrElse(throw new ConnectException(
s"""Failed to connect to a Cassandra cluster.
|${this.getClass.getName} has not been started yet or is not configured properly.""".stripMargin))

def taskClass: Class[_ <: Task]

Expand All @@ -86,7 +88,7 @@ private[kafka] trait TaskLifecycle extends Task with ConnectorLike {
cluster = Some(_cluster)
} catch {
case NonFatal(e) =>
logger.info("Unable to start CassandraSinkConnector, shutting down.", e)
logger.info(s"Unable to start ${this.getClass.getName}, shutting down.", e)
_cluster.shutdown()
}
}
Expand Down

0 comments on commit f8b91f9

Please sign in to comment.