From 65b64059a0757444e534b15a50c5a24b53dd1966 Mon Sep 17 00:00:00 2001 From: Shiti Date: Mon, 4 Apr 2016 14:33:12 +0530 Subject: [PATCH] updated build and plugin dependencies for publishing to maven --- build.sbt | 68 +++++++++---------- project/plugins.sbt | 2 +- .../connect/cassandra/ConnectorLike.scala | 8 ++- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/build.sbt b/build.sbt index 967647a..d7b24b4 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := "kafka-connect-cassandra" -version := "0.0.5" +version := "0.0.6" crossScalaVersions := Seq("2.11.7", "2.10.6") @@ -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")) @@ -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 @@ -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, @@ -156,12 +130,34 @@ pomExtra := -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) - diff --git a/project/plugins.sbt b/project/plugins.sbt index fd6bc9e..30f39b0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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") \ No newline at end of file diff --git a/src/main/scala/com/tuplejump/kafka/connect/cassandra/ConnectorLike.scala b/src/main/scala/com/tuplejump/kafka/connect/cassandra/ConnectorLike.scala index 2b5e55e..5804f46 100644 --- a/src/main/scala/com/tuplejump/kafka/connect/cassandra/ConnectorLike.scala +++ b/src/main/scala/com/tuplejump/kafka/connect/cassandra/ConnectorLike.scala @@ -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 { @@ -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] @@ -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() } }