Skip to content

Commit

Permalink
Merge dbc5615 into dd243b3
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflav23 committed May 17, 2016
2 parents dd243b3 + dbc5615 commit 67bc1c7
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 66 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ We publish phantom in 2 formats, stable releases and bleeding edge.

### Latest versions

Check the badges at the top of this README for the latest version. The badges are automatically updated in realtime, where as this README isn't.
The latest versions are available here. The badges automatically update when a new version is released.

- Latest stable version: [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.websudos/phantom_2.10/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.websudos/phantom_2.10) (Maven Central)
- Latest stable version: [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.websudos/phantom-dsl_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.websudos/phantom-dsl_2.11) (Maven Central)
- Bleeding edge: [![Bintray](https://api.bintray.com/packages/websudos/oss-releases/phantom/images/download.svg) ](https://bintray.com/websudos/oss-releases/phantom/_latestVersion) (Websudos OSS releases on Bintray)

<a id="learning-phantom">Tutorials on phantom and Cassandra</a>
Expand All @@ -45,6 +45,7 @@ This is a list of resources to help you learn phantom and Cassandra:
- [ ] [The official Scala API docs for phantom](http://phantom-docs.s3-website-eu-west-1.amazonaws.com/)
- [ ] [The main Wiki](https://github.com/outworkers/phantom/wiki)
- [ ] The StackOverflow [phantom-dsl](http://stackoverflow.com/questions/tagged/phantom-dsl) tag, which we always monitor!
- [ ] Anything tagged phantom on our blog is a phantom tutorial: [phantom tutorials](http://outworkers.com/blog/tag/phantom)
- [ ] [A series on Cassandra: Getting rid of the SQL mentality](http://outworkers.com/blog/post/a-series-on-cassandra-part-1-getting-rid-of-the-sql-mentality)
- [ ] [A series on Cassandra: Indexes and keys](http://outworkers.com/blog/post/a-series-on-cassandra-part-2-indexes-and-keys)
- [ ] [A series on Cassandra: Advanced features](http://outworkers.com/blog/post/a-series-on-cassandra-part-3-advanced-features)
Expand Down Expand Up @@ -139,14 +140,3 @@ Contributing to phantom
<a href="#table-of-contents">back to top</a>

Contributions are most welcome! Use GitHub for issues and pull requests and we will happily help out in any way we can!

YourKit Java Profiler
==================

![yourkit](https://s3-eu-west-1.amazonaws.com/websudos/oss/yklogo.png "YourKit Java Profiler")

We are very grateful to have the license support of YourKit, the most advanced Java profiler.

YourKit is the very core of our performance bottleneck testing, and without it phantom would still be a painfully slow tool.

[YourKit Java profiler](https://www.yourkit.com/java/profiler/index.jsp)
22 changes: 16 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ val RunningUnderCi = Option(System.getenv("CI")).isDefined || Option(System.gete
val defaultConcurrency = 4

val liftVersion: String => String = {
case "2.10.5" => "3.0-M1"
case _ => "3.0-M6"
s => CrossVersion.partialVersion(s) match {
case Some((major, minor)) if minor >= 11 => "3.0-M6"
case _ => "3.0-M1"
}
}

val scalaMacroDependencies: String => Seq[ModuleID] = {
s => CrossVersion.partialVersion(s) match {
case Some((major, minor)) if minor >= 11 => Seq.empty
case _ => Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full))
}
}

val PerformanceTest = config("perf").extend(Test)
Expand Down Expand Up @@ -103,7 +112,8 @@ val sharedSettings: Seq[Def.Setting[_]] = Defaults.coreDefaultSettings ++ Seq(
organization := "com.websudos",
scalaVersion := "2.11.7",
credentials ++= defaultCredentials,
crossScalaVersions := Seq("2.10.5", "2.11.7"),
crossScalaVersions := Seq("2.10.6", "2.11.8"),
commands in ThisBuild ++= Seq(PublishTasks.mavenPublishingCommand, PublishTasks.bintrayPublishingCommand),
resolvers ++= Seq(
"Typesafe repository snapshots" at "http://repo.typesafe.com/typesafe/snapshots/",
"Typesafe repository releases" at "http://repo.typesafe.com/typesafe/releases/",
Expand All @@ -130,8 +140,7 @@ val sharedSettings: Seq[Def.Setting[_]] = Defaults.coreDefaultSettings ++ Seq(
libraryDependencies ++= Seq(
"ch.qos.logback" % "logback-classic" % Versions.logback,
"org.slf4j" % "log4j-over-slf4j" % Versions.slf4j
),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full),
) ++ scalaMacroDependencies(scalaVersion.value),
fork in Test := true,
javaOptions in ThisBuild ++= Seq(
"-Xmx2G",
Expand Down Expand Up @@ -286,13 +295,14 @@ lazy val phantomSbtPlugin = (project in file("phantom-sbt"))
).settings(
name := "phantom-sbt",
moduleName := "phantom-sbt",
scalaVersion := "2.10.5",
scalaVersion := "2.10.6",
publish := {
CrossVersion.partialVersion(scalaVersion.value).map {
case (2, scalaMajor) if scalaMajor >= 11 => false
case _ => true
}
},
publishMavenStyle := false,
excludeFilter := {
CrossVersion.partialVersion(scalaVersion.value) match {
// if scala 2.11+ is used, quasiquotes are merged into scala-reflect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,35 @@ trait DefaultPrimitives {

override def clz: Class[java.nio.ByteBuffer] = classOf[java.nio.ByteBuffer]
}

}

object Primitive extends DefaultPrimitives {
def apply[RR: Primitive]: Primitive[RR] = implicitly[Primitive[RR]]


def apply[T <: Enumeration](enum: T): Primitive[T#Value] = {
new Primitive[T#Value] {

override type PrimitiveType = java.lang.String

override def cassandraType: String = Primitive[String].cassandraType

override def fromRow(name: String, row: Row): Try[T#Value] = {
nullCheck(name, row) {
r => enum.values.find(_.toString == r.getString(name)) match {
case Some(value) => value
case _ => throw new Exception(s"Value $name not found in enumeration") with NoStackTrace
}
}
}

override def asCql(value: T#Value): String = Primitive[String].asCql(value.toString)

override def fromString(value: String): T#Value = enum.values.find(value == _.toString).getOrElse(None.orNull)

override def clz: Class[String] = classOf[java.lang.String]
}
}

}
37 changes: 27 additions & 10 deletions phantom-sbt/src/main/scala/com/websudos/phantom/sbt/SbtPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,20 @@ object PhantomSbtPlugin extends AutoPlugin {
val phantomStartEmbeddedCassandra = taskKey[Unit]("Starts embedded Cassandra")
val phantomCleanupEmbeddedCassandra = taskKey[Unit]("Clean up embedded Cassandra by dropping all of its keyspaces")
val phantomCassandraConfig = settingKey[Option[File]]("YAML file for Cassandra configuration")
val phantomCassandraTimeout = settingKey[Option[Int]]("Timeout in milliseconds for embedded Cassandra to start")
}

import autoImport._

override def projectSettings: Seq[Def.Setting[_]] = Seq(
phantomCassandraConfig := None,
phantomStartEmbeddedCassandra := EmbeddedCassandra.start(phantomCassandraConfig.value, streams.value.log),
phantomStartEmbeddedCassandra := EmbeddedCassandra.start(streams.value.log, phantomCassandraConfig.value),
phantomCleanupEmbeddedCassandra := EmbeddedCassandra.cleanup(streams.value.log),
test in Test <<= (test in Test).dependsOn(phantomStartEmbeddedCassandra),
testQuick in Test <<= (testQuick in Test).dependsOn(phantomStartEmbeddedCassandra),
testOnly in Test <<= (testOnly in Test).dependsOn(phantomStartEmbeddedCassandra),
phantomCassandraTimeout := None,
phantomStartEmbeddedCassandra := EmbeddedCassandra.start(streams.value.log, phantomCassandraConfig.value, phantomCassandraTimeout.value),
fork := true
)
}
Expand All @@ -107,26 +110,39 @@ object EmbeddedCassandra {
* Starts Cassandra in embedded mode if it has not been
* started yet.
*/
def start (config: Option[File], logger: Logger): Unit = {
logger.info("Initialising EmbeddedCassandra singleton.")
def start (config: Option[File], timeout: Option[Int], logger: Logger): Unit = {
this.synchronized {
if (started.compareAndSet(false, true)) {
blocking {
val configFile = config.map(_.toURI.toString) getOrElse EmbeddedCassandraServerHelper.DEFAULT_CASSANDRA_YML_FILE
System.setProperty("cassandra.config", configFile)
Try {
try {
EmbeddedCassandraServerHelper.mkdirs()
} recover {
} catch {
case NonFatal(e) =>
logger.error(s"Error creating Embedded cassandra directories: ${e.getMessage}")
}

config match {
case Some(file) =>
(config, timeout) match {
case (Some(file), None) =>
logger.info(s"Starting Cassandra in embedded mode with configuration from $file.")
EmbeddedCassandraServerHelper.startEmbeddedCassandra(file,
EmbeddedCassandraServerHelper.DEFAULT_TMP_DIR, EmbeddedCassandraServerHelper.DEFAULT_STARTUP_TIMEOUT)
case None =>
EmbeddedCassandraServerHelper.startEmbeddedCassandra(
file,
EmbeddedCassandraServerHelper.DEFAULT_TMP_DIR,
EmbeddedCassandraServerHelper.DEFAULT_STARTUP_TIMEOUT
)
case (Some(file), Some(time)) =>
logger.info(s"Starting Cassandra in embedded mode with configuration from $file and timeout set to $timeout ms.")
EmbeddedCassandraServerHelper.startEmbeddedCassandra(
file,
EmbeddedCassandraServerHelper.DEFAULT_TMP_DIR,
time
)

case (None, Some(time)) =>
logger.info(s"Starting Cassandra in embedded mode with default configuration and timeout set to $timeout ms.")
EmbeddedCassandraServerHelper.startEmbeddedCassandra(time)
case (None, None) =>
logger.info("Starting Cassandra in embedded mode with default configuration.")
EmbeddedCassandraServerHelper.startEmbeddedCassandra()
}
Expand All @@ -138,6 +154,7 @@ object EmbeddedCassandra {
}
}


def cleanup(logger: Logger): Unit = {
this.synchronized {
if (started.get()) {
Expand Down
60 changes: 23 additions & 37 deletions project/PublishTasks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
import com.typesafe.sbt.pgp.PgpKeys._
import sbt._
import sbt.Keys._
import bintray.BintrayKeys._
import sbt.Keys._
import sbt._

object PublishTasks {

val defaultPublishingSettings = Seq(
version := "1.26.1"
version := "1.26.2"
)

val bintrayPublishSettings: Seq[Def.Setting[_]] = Seq(
Expand Down Expand Up @@ -83,41 +82,28 @@ object PublishTasks {
</developers>
) ++ defaultPublishingSettings

lazy val mavenPublishSettings : TaskKey[Unit] = TaskKey[Unit]("mavenPublishSettings")

lazy val mavenPublishConfiguration = TaskKey[PublishConfiguration](
"mavenPublishConfiguration",
"Changed the configuration to a Sonatype publishing one"
)

lazy val publishToMavenCentral = taskKey[Unit]("publishToMavenCentral")

val printedPublishing = settingKey[Option[String]]("printedPublishing")
val RunningUnderCi = Option(System.getenv("CI")).isDefined || Option(System.getenv("TRAVIS")).isDefined

val mavenTaskSettings: Seq[Def.Setting[_]] = Seq(
mavenPublishSettings := mavenPublishingSettings,
mavenPublishConfiguration <<= (
mavenPublishSettings,
signedArtifacts,
publishTo,
deliver,
checksums in publish,
ivyLoggingLevel
) map { (_, arts, publishTo, ivyFile, checks, level) => {}
Classpaths.publishConfig(
arts,
None,
resolverName = Classpaths.getPublishTo(publishTo).name,
checksums = checks,
logging = level,
overwrite = false
)
},
publishToMavenCentral <<= Classpaths.publishTask(mavenPublishConfiguration, deliver)
.dependsOn(mavenPublishConfiguration)
)
def mavenPublishingCommand: Command = Command.command("publishToMaven") { state =>
val extracted: Extracted = Project.extract(state)
Project.runTask(
publish in Compile,
extracted.append(mavenPublishingSettings, state),
checkCycles = true
)
state
}

val RunningUnderCi = Option(System.getenv("CI")).isDefined || Option(System.getenv("TRAVIS")).isDefined
def bintrayPublishingCommand: Command = Command.command("publishToBintray") { state =>
val extracted: Extracted = Project.extract(state)
Project.runTask(
publish in Compile,
extracted.append(bintrayPublishSettings, state),
checkCycles = true
)
state
}

lazy val effectivePublishingSettings = if (RunningUnderCi) bintrayPublishSettings else mavenPublishingSettings
//lazy val effectivePublishingSettings = mavenPublishingSettings
}

0 comments on commit 67bc1c7

Please sign in to comment.