diff --git a/.travis.yml b/.travis.yml index e51d6050b..97e278aec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,35 @@ sudo: false matrix: include: - scala: 2.10.6 - script: ./sbt "+++$TRAVIS_SCALA_VERSION clean" "+++$TRAVIS_SCALA_VERSION scalafmtTest" "+++$TRAVIS_SCALA_VERSION test" "+++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues" + script: ./sbt ++$TRAVIS_SCALA_VERSION clean scalafmtTest test mimaReportBinaryIssues - scala: 2.11.8 - script: ./sbt "+++$TRAVIS_SCALA_VERSION clean" "+++$TRAVIS_SCALA_VERSION scalafmtTest" "+++$TRAVIS_SCALA_VERSION test" "+++$TRAVIS_SCALA_VERSION coverageReport" "+++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues" + script: ./sbt ++$TRAVIS_SCALA_VERSION clean coverage scalafmtTest test coverageReport mimaReportBinaryIssues + after_success: + - bash <(curl -s https://codecov.io/bash) - - scala: 2.12.0 + - scala: 2.12.1 jdk: oraclejdk8 script: ./sbt "+++$TRAVIS_SCALA_VERSION clean" "+++$TRAVIS_SCALA_VERSION test" - after_success: - - bash <(curl -s https://codecov.io/bash) + +cache: + directories: + - $HOME/.sbt/0.13/dependency + - $HOME/.sbt/boot/scala* + - $HOME/.sbt/launchers + - $HOME/.ivy2/cache + - $HOME/.nvm + +before_cache: + - du -h -d 1 $HOME/.ivy2/cache + - du -h -d 2 $HOME/.sbt/ + - find $HOME/.sbt -name "*.lock" -type f -delete + - find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/823bad727793c3cd3caf + on_success: change + on_failure: always + on_start: never diff --git a/README.md b/README.md index 1feeb0ba7..5f992876b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -## Bijection [![Build Status](https://secure.travis-ci.org/twitter/bijection.png)](http://travis-ci.org/twitter/bijection) [![Codecov](https://img.shields.io/codecov/c/github/twitter/bijection.svg?maxAge=2592000)](https://codecov.io/github/twitter/bijection) +## Bijection + +[![Build Status](https://secure.travis-ci.org/twitter/bijection.png)](http://travis-ci.org/twitter/bijection) [![Codecov](https://img.shields.io/codecov/c/github/twitter/bijection.svg?maxAge=2592000)](https://codecov.io/github/twitter/bijection) +[![Latest version](https://index.scala-lang.org/twitter/bijection/bijection-core/latest.svg?color=orange)](https://index.scala-lang.org/twitter/bijection/bijection-core) +[![Chat](https://badges.gitter.im/twitter/bijection.svg)](https://gitter.im/twitter/bijection?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) A Bijection is an invertible function that converts back and forth between two types, with the contract that a round-trip through the Bijection will bring back the original object. Moreover, @@ -131,7 +135,7 @@ The latest ScalaDocs are hosted on Bijection's [Github Project Page](http://twit ## Get Involved + Code of Conduct Pull requests and bug reports are always welcome! -Discussion occurs primarily on the [Bijection mailing list](https://groups.google.com/forum/#!forum/bijection). +Discussion occurs primarily on the [Bijection mailing list](https://groups.google.com/forum/#!forum/bijection). Issues should be reported on the [GitHub issue tracker](https://github.com/twitter/bijection/issues). We use a lightweight form of project governence inspired by the one used by Apache projects. @@ -162,7 +166,7 @@ Current published artifacts are Every artifact is published against Scala `"2.10"` and `"2.11"`. We currently publish a subset of bijection's modules against Scala `"2.12"`. Bijection modules - bijection-util and bijection-scrooge depend on other projects to publish 2.12 artifacts and currently aren't being published. To pull in the jars, make sure to add your desired scala version as a suffix, ie: -`bijection-core_2.10` or `bijection-core_2.11` or `bijection-core_2.12`. +`bijection-core_2.10` or `bijection-core_2.11` or `bijection-core_2.12`. ## Chat [![Gitter](https://badges.gitter.im/twitter/bijection.svg)](https://gitter.im/twitter/bijection?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) diff --git a/build.sbt b/build.sbt index f2b5e160b..0d726c097 100644 --- a/build.sbt +++ b/build.sbt @@ -5,13 +5,25 @@ import com.typesafe.sbt.osgi.SbtOsgi.autoImport._ import ReleaseTransformations._ // for sbt-release. import bijection._ +val finagleVersion = "6.25.0" +val scalatestVersion = "3.0.1" +val scalacheckVersion = "1.13.4" +val utilVersion = "6.34.0" +val utilVersion212 = "6.39.0" + +def util(mod: String, scalaVersion: String) = { + val version = + if (scalaVersion startsWith "2.12") utilVersion212 + else utilVersion + "com.twitter" %% (s"util-$mod") % version +} + val buildLevelSettings = Seq( organization := "com.twitter", - crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.0"), + crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1"), javacOptions ++= Seq("-source", "1.6", "-target", "1.6"), javacOptions in doc := Seq("-source", "1.6"), scalaVersion := "2.11.8", - coverageEnabled := (if (scalaVersion.value startsWith "2.11") true else false), scalacOptions ++= Seq( "-unchecked", "-deprecation", @@ -33,8 +45,8 @@ val buildLevelSettings = Seq( "releases" at "https://oss.sonatype.org/content/repositories/releases" ), libraryDependencies ++= Seq( - "org.scalacheck" %% "scalacheck" % "1.13.4" % "test", - "org.scalatest" %% "scalatest" % "3.0.1" % "test" + "org.scalacheck" %% "scalacheck" % scalacheckVersion % "test", + "org.scalatest" %% "scalatest" % scalatestVersion % "test" ), parallelExecution in Test := true, homepage := Some(url("https://github.com/twitter/bijection")), @@ -140,8 +152,8 @@ lazy val bijection = { Project( id = "bijection", base = file("."), - settings = buildLevelSettings ++ sharedSettings - ).enablePlugins(DocGen, SbtOsgi, CrossPerProjectPlugin) + settings = buildLevelSettings ++ sharedSettings + ).enablePlugins(SbtOsgi, CrossPerProjectPlugin) .settings( test := {}, publish := {}, // skip publishing for this root project. @@ -249,8 +261,8 @@ lazy val bijectionScrooge = { libraryDependencies ++= Seq( "org.apache.thrift" % "libthrift" % "0.6.1" exclude ("junit", "junit"), "com.twitter" %% "scrooge-serializer" % "3.17.0", - "com.twitter" %% "util-core" % "6.24.0", - "com.twitter" %% "finagle-core" % "6.25.0" % "test" + util("core", scalaVersion.value), + "com.twitter" %% "finagle-core" % finagleVersion % "test" ) ).dependsOn( bijectionCore % "test->test;compile->compile", @@ -270,9 +282,8 @@ lazy val bijectionJson = { lazy val bijectionUtil = { module("util").settings( - crossScalaVersions := crossScalaVersions.value.filterNot(_.startsWith("2.12")), osgiExportAll("com.twitter.bijection.twitter_util"), - libraryDependencies += "com.twitter" %% "util-core" % "6.24.0" + libraryDependencies += util("core", scalaVersion.value) ).dependsOn( bijectionCore % "test->test;compile->compile" ) @@ -283,8 +294,8 @@ lazy val bijectionFinagleMySql = { crossScalaVersions := crossScalaVersions.value.filterNot(_.startsWith("2.12")), osgiExportAll("com.twitter.bijection.finagle_mysql"), libraryDependencies ++= Seq( - "com.twitter" %% "finagle-mysql" % "6.25.0", - "com.twitter" %% "util-core" % "6.24.0" + "com.twitter" %% "finagle-mysql" % finagleVersion, + util("core", scalaVersion.value) ) ).dependsOn( bijectionCore % "test->test;compile->compile" diff --git a/project/DocGen.scala b/project/DocGen.scala deleted file mode 100644 index 811f4dec3..000000000 --- a/project/DocGen.scala +++ /dev/null @@ -1,50 +0,0 @@ -package bijection - -import sbt._ -import Keys._ - -import com.typesafe.sbt.git.GitRunner -import com.typesafe.sbt.SbtGit.GitKeys -import com.typesafe.sbt.SbtSite.{site, SiteKeys} -import com.typesafe.sbt.SbtGhPages.{ghpages, GhPagesKeys => ghkeys} -import com.typesafe.sbt.SbtGit.GitKeys.gitRemoteRepo - -object DocGen extends AutoPlugin { - - override def requires = Unidoc - - val docDirectory = "target/site" - val aggregateName = "bijection" - - def syncLocal = Def.task { - val repo = ghkeys.updatedRepository.value - val git = GitKeys.gitRunner.value - cleanSite(repo, git, streams.value) // First, remove 'stale' files. - val rootPath = file(docDirectory) // Now copy files. - IO.copyDirectory(rootPath, repo) - IO.touch(repo / ".nojekyll") - repo - } - - private def cleanSite(dir: File, git: GitRunner, s: TaskStreams): Unit = { - val toClean = IO.listFiles(dir).filterNot(_.getName == ".git").map(_.getAbsolutePath).toList - if (!toClean.isEmpty) - git(("rm" :: "-r" :: "-f" :: "--ignore-unmatch" :: toClean): _*)(dir, s.log) - () - } - - def unidocSettings: Seq[sbt.Setting[_]] = - site.includeScaladoc(docDirectory) ++ Seq( - scalacOptions in doc ++= { - val tagOrBranch = if (version.value.endsWith("-SNAPSHOT")) "develop" else version.value - val docSourceUrl = "https://github.com/twitter/" + aggregateName + "/tree/" + tagOrBranch + "€{FILE_PATH}.scala" - Seq("-sourcepath", baseDirectory.value.getAbsolutePath, "-doc-source-url", docSourceUrl) - }, - Unidoc.unidocDirectory := file(docDirectory), - gitRemoteRepo := "git@github.com:twitter/" + aggregateName + ".git", - ghkeys.synchLocal := syncLocal.value - ) - - override def projectSettings = site.settings ++ ghpages.settings ++ unidocSettings - -} diff --git a/project/Unidoc.scala b/project/Unidoc.scala deleted file mode 100644 index 45230cde2..000000000 --- a/project/Unidoc.scala +++ /dev/null @@ -1,64 +0,0 @@ -package bijection - -import sbt._ -import sbt.Keys._ -import sbt.Project.Initialize - -/** Borrowed from https://github.com/akka/akka/blob/master/project/Unidoc.scala */ -object Unidoc extends AutoPlugin { - - override def requires = plugins.JvmPlugin - - val unidocDirectory = SettingKey[File]("unidoc-directory") - val unidocAllSources = TaskKey[Seq[File]]("unidoc-all-sources") - val unidocSources = TaskKey[Seq[File]]("unidoc-sources") - val unidocAllClasspaths = TaskKey[Seq[Classpath]]("unidoc-all-classpaths") - val unidocClasspath = TaskKey[Seq[File]]("unidoc-classpath") - val unidoc = TaskKey[File]("unidoc", "Create unified scaladoc for all aggregates") - - override def projectSettings = Seq( - unidocDirectory := crossTarget.value / "unidoc", - unidocAllSources := Def.taskDyn { - val projectRef = thisProjectRef.value - val structure = buildStructure.value - val projects = aggregated(projectRef, structure) - val compositeTask = projects.map { proj => - (sources in (proj, Compile)) - }.join - compositeTask - }.value.flatten, - unidocSources := unidocAllSources.value, - unidocAllClasspaths := Def.taskDyn { - val projectRef = thisProjectRef.value - val structure = buildStructure.value - val projects = aggregated(projectRef, structure) - val compositeTask = projects.map { proj => - (dependencyClasspath in (proj, Compile)) - }.join - compositeTask - }.value, - unidocClasspath := unidocAllClasspaths.value.flatten.map(_.data).distinct, - unidoc := { - val scaladoc = Doc.scaladoc("main", streams.value.cacheDirectory / "unidoc", compilers.value.scalac) - scaladoc( - unidocSources.value, - unidocClasspath.value, - unidocDirectory.value, - (scalacOptions in doc).value, - 100, - streams.value.log - ) - unidocDirectory.value - } - ) - - def aggregated( - projectRef: ProjectRef, - structure: BuildStructure - ): Seq[ProjectRef] = { - val maybeProject: Option[ResolvedProject] = Project.getProjectForReference(projectRef, structure) - val aggregatedRefs: Seq[ProjectRef] = maybeProject.toSeq.flatMap(_.aggregate) - aggregatedRefs flatMap { ref => ref +: aggregated(ref, structure) } - } - -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 3e2a5d056..3ff8bcaf1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,11 +2,11 @@ resolvers ++= Seq( "jgit-repo" at "http://download.eclipse.org/jgit/maven" ) -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3") -addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.11") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4") -addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3") +addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.12") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4") +addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")