Skip to content

WIP: Add Dotty build for kernel only #2629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ git:
scala:
- 2.11.12
- 2.13.0-M5
- 0.10.0-RC1
- 2.12.7

jdk:
Expand Down Expand Up @@ -46,6 +47,11 @@ env:
- secure: QbNAu0jCaKrwjJi7KZtYEBA/pYbTJ91Y1x/eLAJpsamswVOvwnThA/TLYuux+oiZQCiDUpBzP3oxksIrEEUAhl0lMtqRFY3MrcUr+si9NIjX8hmoFwkvZ5o1b7pmLF6Vz3rQeP/EWMLcljLzEwsrRXeK0Ei2E4vFpsg8yz1YXJg=
- TRAVIS_NODE_VERSION="4"

matrix:
exclude:
- scala: 0.10.0-RC1
env: JS_BUILD=true

cache:
directories:
- $HOME/.m2
Expand All @@ -54,4 +60,3 @@ cache:
- $HOME/.coursier
# Pants cache
- $HOME/.cache

37 changes: 34 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ lazy val commonSettings = Seq(
extraDirs("-2.12-")
case Some((2, y)) if y >= 13 =>
extraDirs("-2.13+")
case Some((0, 10)) =>
extraDirs("-0.10")
case _ => Nil
}
},
Expand Down Expand Up @@ -382,6 +384,7 @@ lazy val docs = project
.settings(moduleName := "cats-docs")
.settings(catsSettings)
.settings(noPublishSettings)
.settings(noDottySettings)
.settings(docSettings)
.settings(commonJvmSettings)
.dependsOn(coreJVM, freeJVM, kernelLawsJVM, lawsJVM, testkitJVM)
Expand All @@ -391,13 +394,15 @@ lazy val cats = project
.settings(moduleName := "root")
.settings(catsSettings)
.settings(noPublishSettings)
.settings(noDottySettings)
.aggregate(catsJVM, catsJS)
.dependsOn(catsJVM, catsJS, testsJVM % "test-internal -> test")

lazy val catsJVM = project
.in(file(".catsJVM"))
.settings(moduleName := "cats")
.settings(noPublishSettings)
.settings(noDottySettings)
.settings(catsSettings)
.settings(commonJvmSettings)
.aggregate(macrosJVM,
Expand Down Expand Up @@ -432,6 +437,7 @@ lazy val catsJS = project
.in(file(".catsJS"))
.settings(moduleName := "cats")
.settings(noPublishSettings)
.settings(noDottySettings)
.settings(catsSettings)
.settings(commonJsSettings)
.aggregate(macrosJS,
Expand Down Expand Up @@ -466,6 +472,7 @@ lazy val macros = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "cats-macros", name := "Cats macros")
.settings(catsSettings)
.settings(noDottySettings)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.jsSettings(coverageEnabled := false)
Expand All @@ -483,9 +490,14 @@ lazy val kernel = crossProject(JSPlatform, JVMPlatform)
.settings(scoverageSettings)
.settings(sourceGenerators in Compile += (sourceManaged in Compile).map(KernelBoiler.gen).taskValue)
.settings(includeGeneratedSrc)
.jsSettings(commonJsSettings)
.jsSettings(commonJsSettings ++ noDottySettings)
.jvmSettings(commonJvmSettings ++ mimaSettings("cats-kernel"))
.settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value) % "test")
Copy link
Contributor

Choose a reason for hiding this comment

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

If you add .withDottyCompat(scalaVersion.value) you should be able to keep this dependency when compiling with Dotty too (https://github.com/lampepfl/dotty-example-project#getting-your-project-to-compile-with-dotty)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh...I missed that!! Cool

.settings(libraryDependencies ++= {
if (!isDotty.value)
Seq("org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value) % "test")
else
Seq()
})

lazy val kernelJVM = kernel.jvm
lazy val kernelJS = kernel.js
Expand All @@ -496,6 +508,7 @@ lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "cats-kernel-laws", name := "Cats kernel laws")
.settings(commonSettings)
.settings(publishSettings)
.settings(noDottySettings)
.settings(scoverageSettings)
.settings(disciplineDependencies)
.settings(testingDependencies)
Expand All @@ -512,6 +525,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
.dependsOn(macros, kernel)
.settings(moduleName := "cats-core", name := "Cats core")
.settings(catsSettings)
.settings(noDottySettings)
.settings(sourceGenerators in Compile += (sourceManaged in Compile).map(Boilerplate.gen).taskValue)
.settings(includeGeneratedSrc)
.settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value) % "test")
Expand All @@ -526,6 +540,7 @@ lazy val laws = crossProject(JSPlatform, JVMPlatform)
.dependsOn(macros, kernel, core, kernelLaws)
.settings(moduleName := "cats-laws", name := "Cats laws")
.settings(catsSettings)
.settings(noDottySettings)
.settings(disciplineDependencies)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
Expand All @@ -540,6 +555,7 @@ lazy val free = crossProject(JSPlatform, JVMPlatform)
.dependsOn(macros, core, tests % "test-internal -> test")
.settings(moduleName := "cats-free", name := "Cats Free")
.settings(catsSettings)
.settings(noDottySettings)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings ++ mimaSettings("cats-free"))

Expand All @@ -552,6 +568,7 @@ lazy val tests = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "cats-tests")
.settings(catsSettings)
.settings(noPublishSettings)
.settings(noDottySettings)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)

Expand All @@ -566,6 +583,7 @@ lazy val testkit = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "cats-testkit")
.settings(catsSettings)
.settings(disciplineDependencies)
.settings(noDottySettings)
.settings(libraryDependencies += "org.scalatest" %%% "scalatest" % scalatestVersion(scalaVersion.value))
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
Expand All @@ -585,6 +603,7 @@ lazy val alleycatsCore = crossProject(JSPlatform, JVMPlatform)
)
.settings(catsSettings)
.settings(publishSettings)
.settings(noDottySettings)
.settings(scoverageSettings)
.settings(includeGeneratedSrc)
.jsSettings(commonJsSettings)
Expand All @@ -601,6 +620,7 @@ lazy val alleycatsLaws = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "alleycats-laws", name := "Alleycats laws")
.settings(catsSettings)
.settings(publishSettings)
.settings(noDottySettings)
.settings(scoverageSettings)
.settings(disciplineDependencies)
.settings(testingDependencies)
Expand All @@ -619,6 +639,7 @@ lazy val alleycatsTests = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "alleycats-tests")
.settings(catsSettings)
.settings(noPublishSettings)
.settings(noDottySettings)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)

Expand All @@ -632,6 +653,7 @@ lazy val bench = project
.settings(moduleName := "cats-bench")
.settings(catsSettings)
.settings(noPublishSettings)
.settings(noDottySettings)
.settings(commonJvmSettings)
.settings(coverageEnabled := false)
.settings(
Expand All @@ -646,6 +668,7 @@ lazy val bench = project
lazy val binCompatTest = project
.disablePlugins(CoursierPlugin)
.settings(noPublishSettings)
.settings(noDottySettings)
.settings(
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.8"),
libraryDependencies ++= List(
Expand All @@ -665,6 +688,7 @@ lazy val js = project
.dependsOn(macrosJS, coreJS, testsJS % "test-internal -> test")
.settings(moduleName := "cats-js")
.settings(catsSettings)
.settings(noDottySettings)
.settings(commonJsSettings)
.enablePlugins(ScalaJSPlugin)

Expand All @@ -673,6 +697,7 @@ lazy val jvm = project
.dependsOn(macrosJVM, coreJVM, testsJVM % "test-internal -> test")
.settings(moduleName := "cats-jvm")
.settings(catsSettings)
.settings(noDottySettings)
.settings(commonJvmSettings)

lazy val publishSettings = Seq(
Expand Down Expand Up @@ -790,6 +815,10 @@ addCommandAlias("prePR", ";fmt;validateBC")

addCommandAlias("gitSnapshots", ";set version in ThisBuild := git.gitDescribedVersion.value.get + \"-SNAPSHOT\"")

lazy val noDottySettings = Seq(
crossScalaVersions ~= {_.filterNot(Set("0.10.0-RC1"))}
)

lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
Expand Down Expand Up @@ -878,7 +907,8 @@ lazy val warnUnusedImport = Seq(
Seq("-Ywarn-unused-import")
case Some((2, n)) if n >= 12 =>
Seq("-Ywarn-unused:imports")

case Some((0, 10)) =>
Seq("-Ywarn-unused:imports")
Copy link
Contributor

Choose a reason for hiding this comment

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

That setting doesn't exist in Dotty currently

}
},
scalacOptions in (Compile, console) ~= { _.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports")) },
Expand Down Expand Up @@ -906,6 +936,7 @@ lazy val xlint = Seq(
scalacOptions += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Xlint:-unused,_"
case Some((0, 10)) => "-Xlint:-unused,_"
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no -Xlint in Dotty currently (and I hope scalafix can completely replace -Xlint)

case _ => "-Xlint"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cats.kernel
package compat

private[kernel] object TraversableOnce {
def reduceOption[A, A1 >: A](as: TraversableOnce[A], op: (A1, A1) => A1): Option[A1] =
as.reduceOption(op)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cats.kernel
package compat

import scala.collection.mutable

abstract private[kernel] class WrappedMutableMapBase[K, V](m: mutable.Map[K, V]) extends Map[K, V] {
override def updated[V2 >: V](key: K, value: V2): Map[K, V2] = m.toMap + ((key, value))
def +[V2 >: V](kv: (K, V2)): Map[K, V2] = m.toMap + kv
def -(key: K): Map[K, V] = m.toMap - key
}
2 changes: 1 addition & 1 deletion kernel/src/main/scala/cats/kernel/instances/char.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package instances
package object char extends CharInstances

trait CharInstances {
implicit val catsKernelStdOrderForChar = new CharOrder
implicit val catsKernelStdOrderForChar: CharOrder = new CharOrder
}

class CharOrder extends Order[Char] with Hash[Char] {
Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.25")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.8")
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.4")
Copy link
Contributor

Choose a reason for hiding this comment

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

Latest is 0.2.6 (looks like we forgot to update the example projects)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed... my proof that I did Read The Fantastic Manual, but missed the important bit.

6 changes: 4 additions & 2 deletions scripts/travis-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ else
jvm="$sbt_cmd coverage validateJVM coverageReport && codecov"
fi



if [[ $TRAVIS_SCALA_VERSION == *"2.12"* ]]; then
scalafix="cd scalafix && sbt tests/test && cd .. &&"
else
Expand All @@ -60,4 +58,8 @@ else
run_cmd="$scalafix $jvm && $sbt_cmd $publish_cmd"
fi

if [[ $TRAVIS_SCALA_VERSION == *"0.10"* ]]; then
run_cmd="$sbt_cmd kernelJVM/publishLocal"
fi

eval $run_cmd