Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
maxColumn = 180
style = defaultWithAlign
optIn.breaksInsideChains = true
37 changes: 14 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ cache:
- $HOME/.m2/repository/
- $HOME/.ivy2/cache/
- $HOME/.sbt/boot/
- $HOME/.coursier

sudo: false

jdk:
- openjdk7
- oraclejdk8

branches:
only:
- develop

script:
- ./sbt jcheckStyle
- ./sbt test
- ./sbt test -J-Dmsgpack.universal-buffer=true

matrix:
include:
- dist: trusty
- env: PROJECT=checkstyle
jdk: oraclejdk8
script:
- ./sbt jcheckStyle
- env: PROJECT=java8
jdk: oraclejdk8
script:
- ./sbt test
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add sbt ";scalafmt::test ;test:scalafmt::test ;sbt:scalafmt::test" ?

https://github.com/lucidsoftware/neo-sbt-scalafmt/blob/1.14/README.md#usage
https://github.com/sbt/sbt/blob/v1.0.4/.travis.yml#L20

To ensure everything is formatted, and fail if it is not (e.g. as a CI step),

> scalafmt::test # check compile sources
> test:scalafmt::test # check test sources
> sbt:scalafmt::test # check .sbt sources

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, Maybe I was wrong. You added addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.3.0"), not neo-sbt-scalafmt 🙇

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. sbt-scalafmt reformats everything including main, test, *.sbt, etc.

- ./sbt test -J-Dmsgpack.universal-buffer=true
- env: PROJECT=java9
dist: trusty
group: edge
sudo: required
jdk: oraclejdk9
Expand All @@ -32,16 +34,5 @@ matrix:
packages:
- oracle-java9-installer
script:
# https://github.com/sbt/sbt/pull/2951
- git clone https://github.com/retronym/java9-rt-export
- cd java9-rt-export/
- git checkout 1019a2873d057dd7214f4135e84283695728395d
- echo "sbt.version=1.0.2" > project/build.properties
- sbt package
- mkdir -p $HOME/.sbt/0.13/java9-rt-ext; java -jar target/java9-rt-export-*.jar $HOME/.sbt/0.13/java9-rt-ext/rt.jar
- jar tf $HOME/.sbt/0.13/java9-rt-ext/rt.jar | grep java/lang/Object
- cd ..
- rm sbt
- wget https://raw.githubusercontent.com/paulp/sbt-extras/3ba0e52f32d32c0454ec3a926caae2db0caaca12/sbt && chmod +x ./sbt
- ./sbt -Dscala.ext.dirs=$HOME/.sbt/0.13/java9-rt-ext test
- ./sbt -Dscala.ext.dirs=$HOME/.sbt/0.13/java9-rt-ext -Dmsgpack.universal-buffer=true test
- ./sbt test
- ./sbt test -J-Dmsgpack.universal-buffer=true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Here is a list of sbt commands for daily development:
> findbugs # Produce findbugs report in target/findbugs
> jacoco:cover # Report the code coverage of tests to target/jacoco folder
> jcheckStyle # Run check style
> scalafmt # Reformat Scala codes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/lucidsoftware/neo-sbt-scalafmt/blob/1.14/README.md#usage

scalafmt # format compile sources
test:scalafmt # format test sources
sbt:scalafmt # format .sbt source

The scalafmt command format only compile sources

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```

### Publishing
Expand Down
155 changes: 76 additions & 79 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,60 +1,53 @@
import de.johoop.findbugs4sbt.ReportType
import ReleaseTransformations._

val buildSettings = findbugsSettings ++ jacoco.settings ++ osgiSettings ++ Seq[Setting[_]](
val buildSettings = Seq[Setting[_]](
organization := "org.msgpack",
organizationName := "MessagePack",
organizationHomepage := Some(new URL("http://msgpack.org/")),
description := "MessagePack for Java",
scalaVersion := "2.11.11",
scalaVersion := "2.12.4",
logBuffered in Test := false,
// msgpack-java should be a pure-java library, so remove Scala specific configurations
autoScalaLibrary := false,
crossPaths := false,
// For performance testing, ensure each test run one-by-one
concurrentRestrictions in Global := Seq(
Tags.limit(Tags.Test, 1)
),
// JVM options for building
scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked", "-target:jvm-1.6", "-feature"),
scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked", "-target:jvm-1.7", "-feature"),
javaOptions in Test ++= Seq("-ea"),
javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.6", "-target", "1.6"),
javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.7", "-target", "1.7"),
// Use lenient validation mode when generating Javadoc (for Java8)
javacOptions in doc := {
val opts = Seq("-source", "1.6")
val opts = Seq("-source", "1.7")
if (scala.util.Properties.isJavaAtLeast("1.8")) {
opts ++ Seq("-Xdoclint:none")
}
else {
} else {
opts
}
},
// Release settings
releaseTagName := { (version in ThisBuild).value },
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
ReleaseStep(action = Command.process("publishSigned", _)),
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
pushChanges
),

// Jacoco code coverage report
parallelExecution in jacoco.Config := false,

checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommand("publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
),
// Find bugs
findbugsReportType := Some(ReportType.FancyHtml),
findbugsReportType := Some(FindbugsReport.FancyHtml),
findbugsReportPath := Some(crossTarget.value / "findbugs" / "report.html"),

// Style check config: (sbt-jchekcstyle)
jcheckStyleConfig := "facebook",

// Run jcheckstyle both for main and test codes
(compile in Compile) := ((compile in Compile) dependsOn (jcheckStyle in Compile)).value,
(compile in Test) := ((compile in Test) dependsOn (jcheckStyle in Test)).value
Expand All @@ -64,57 +57,61 @@ val junitInterface = "com.novocode" % "junit-interface" % "0.11" % "test"

// Project settings
lazy val root = Project(id = "msgpack-java", base = file("."))
.settings(
buildSettings,
// Do not publish the root project
publishArtifact := false,
publish := {},
publishLocal := {},
findbugs := {
// do not run findbugs for the root project
}
).aggregate(msgpackCore, msgpackJackson)
.settings(
buildSettings,
// Do not publish the root project
publishArtifact := false,
publish := {},
publishLocal := {},
findbugs := {
// do not run findbugs for the root project
}
)
.aggregate(msgpackCore, msgpackJackson)

lazy val msgpackCore = Project(id = "msgpack-core", base = file("msgpack-core"))
.settings(
buildSettings,
description := "Core library of the MessagePack for Java",
OsgiKeys.bundleSymbolicName := "org.msgpack.msgpack-core",
OsgiKeys.exportPackage := Seq(
// TODO enumerate used packages automatically
"org.msgpack.core",
"org.msgpack.core.annotations",
"org.msgpack.core.buffer",
"org.msgpack.value",
"org.msgpack.value.impl"
),
libraryDependencies ++= Seq(
// msgpack-core should have no external dependencies
junitInterface,
"org.scalatest" %% "scalatest" % "3.0.3" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.5" % "test",
"org.xerial" %% "xerial-core" % "3.6.0" % "test",
"org.msgpack" % "msgpack" % "0.6.12" % "test",
"commons-codec" % "commons-codec" % "1.10" % "test",
"com.typesafe.akka" %% "akka-actor" % "2.3.16" % "test"
)
)

lazy val msgpackJackson = Project(id = "msgpack-jackson", base = file("msgpack-jackson"))
.settings(
buildSettings,
name := "jackson-dataformat-msgpack",
description := "Jackson extension that adds support for MessagePack",
OsgiKeys.bundleSymbolicName := "org.msgpack.msgpack-jackson",
OsgiKeys.exportPackage := Seq(
"org.msgpack.jackson",
"org.msgpack.jackson.dataformat"
),
libraryDependencies ++= Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.1",
junitInterface,
"org.apache.commons" % "commons-math3" % "3.6.1" % "test"
),
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")
).dependsOn(msgpackCore)
.enablePlugins(SbtOsgi)
.settings(
buildSettings,
description := "Core library of the MessagePack for Java",
OsgiKeys.bundleSymbolicName := "org.msgpack.msgpack-core",
OsgiKeys.exportPackage := Seq(
// TODO enumerate used packages automatically
"org.msgpack.core",
"org.msgpack.core.annotations",
"org.msgpack.core.buffer",
"org.msgpack.value",
"org.msgpack.value.impl"
),
libraryDependencies ++= Seq(
// msgpack-core should have no external dependencies
junitInterface,
"org.scalatest" %% "scalatest" % "3.0.3" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.5" % "test",
"org.xerial" %% "xerial-core" % "3.6.0" % "test",
"org.msgpack" % "msgpack" % "0.6.12" % "test",
"commons-codec" % "commons-codec" % "1.10" % "test",
"com.typesafe.akka" %% "akka-actor" % "2.5.7" % "test"
)
)

lazy val msgpackJackson =
Project(id = "msgpack-jackson", base = file("msgpack-jackson"))
.enablePlugins(SbtOsgi)
.settings(
buildSettings,
name := "jackson-dataformat-msgpack",
description := "Jackson extension that adds support for MessagePack",
OsgiKeys.bundleSymbolicName := "org.msgpack.msgpack-jackson",
OsgiKeys.exportPackage := Seq(
"org.msgpack.jackson",
"org.msgpack.jackson.dataformat"
),
libraryDependencies ++= Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.1",
junitInterface,
"org.apache.commons" % "commons-math3" % "3.6.1" % "test"
),
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")
)
.dependsOn(msgpackCore)
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ class MessageBufferPackerTest extends MessagePackSpec {
"MessageBufferPacker" should {
"be equivalent to ByteArrayOutputStream" in {
val packer1 = MessagePack.newDefaultBufferPacker
packer1.packValue(newMap(
newString("a"), newInteger(1),
newString("b"), newString("s")))
packer1.packValue(newMap(newString("a"), newInteger(1), newString("b"), newString("s")))

val stream = new ByteArrayOutputStream
val stream = new ByteArrayOutputStream
val packer2 = MessagePack.newDefaultPacker(stream)
packer2.packValue(newMap(
newString("a"), newInteger(1),
newString("b"), newString("s")))
packer2.packValue(newMap(newString("a"), newInteger(1), newString("b"), newString("s")))
packer2.flush

packer1.toByteArray shouldBe stream.toByteArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ import org.scalatest.exceptions.TestFailedException
import scala.util.Random

/**
* Created on 2014/05/07.
*/
class MessageFormatTest
extends MessagePackSpec {
* Created on 2014/05/07.
*/
class MessageFormatTest extends MessagePackSpec {
"MessageFormat" should {
"cover all byte codes" in {
def checkV(b: Byte, tpe: ValueType) {
try
MessageFormat.valueOf(b).getValueType shouldBe tpe
try MessageFormat.valueOf(b).getValueType shouldBe tpe
catch {
case e: TestFailedException =>
error(f"Failure when looking at byte ${b}%02x")
Expand Down Expand Up @@ -80,7 +78,6 @@ class MessageFormatTest
check(Code.EXT16, ValueType.EXTENSION, MessageFormat.EXT16)
check(Code.EXT32, ValueType.EXTENSION, MessageFormat.EXT32)


check(Code.INT8, ValueType.INTEGER, MessageFormat.INT8)
check(Code.INT16, ValueType.INTEGER, MessageFormat.INT16)
check(Code.INT32, ValueType.INTEGER, MessageFormat.INT32)
Expand All @@ -94,7 +91,6 @@ class MessageFormatTest
check(Code.STR16, ValueType.STRING, MessageFormat.STR16)
check(Code.STR32, ValueType.STRING, MessageFormat.STR32)


check(Code.FLOAT32, ValueType.FLOAT, MessageFormat.FLOAT32)
check(Code.FLOAT64, ValueType.FLOAT, MessageFormat.FLOAT64)

Expand All @@ -107,7 +103,7 @@ class MessageFormatTest
}

"improve the valueOf performance" in {
val N = 1000000
val N = 1000000
val idx = (0 until N).map(x => Random.nextInt(256).toByte).toArray[Byte]

// Initialize
Expand Down
18 changes: 4 additions & 14 deletions msgpack-core/src/test/scala/org/msgpack/core/MessagePackSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,22 @@ import xerial.core.util.{TimeReport, Timer}

import scala.language.implicitConversions

trait MessagePackSpec
extends WordSpec
with Matchers
with GivenWhenThen
with OptionValues
with BeforeAndAfter
with PropertyChecks
with Benchmark
with Logger {
trait MessagePackSpec extends WordSpec with Matchers with GivenWhenThen with OptionValues with BeforeAndAfter with PropertyChecks with Benchmark with Logger {

implicit def toTag(s: String): Tag = Tag(s)

def toHex(arr: Array[Byte]) = arr.map(x => f"$x%02x").mkString(" ")

def createMessagePackData(f: MessagePacker => Unit): Array[Byte] = {
val b = new
ByteArrayOutputStream()
val b = new ByteArrayOutputStream()
val packer = MessagePack.newDefaultPacker(b)
f(packer)
packer.close()
b.toByteArray
}
}

trait Benchmark
extends Timer {
trait Benchmark extends Timer {

val numWarmUpRuns = 10

Expand All @@ -66,4 +56,4 @@ trait Benchmark

super.block(name, repeat)(f)
}
}
}
Loading