Skip to content

Commit

Permalink
Add Scala 3.1.0 support
Browse files Browse the repository at this point in the history
Notes: scala3 artifacts are published with `_$major.$minor` postfix
  • Loading branch information
dos65 committed Oct 19, 2021
1 parent a897826 commit d4e4b8c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ jobs:
- "'++2.12.12 test'"
- "'++2.12.14 test' scripted"
- "'++2.13.6 test'"
- "'++3.0.1 test'"
- "'++3.0.2 test'"
- "'++3.1.0 test'"
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v13
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ out/
.bloop/
metals.sbt
.vscode/
.bsp

website/translated_docs
website/build/
Expand Down
20 changes: 17 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import scala.collection.mutable
def scala212 = "2.12.15"
def scala211 = "2.11.12"
def scala213 = "2.13.6"
def scala3 = "3.0.2"
def scala302 = "3.0.2"
def scala3 = "3.1.0"
def scala2Versions = List(scala212, scala211, scala213)
def allScalaVersions = scala2Versions :+ scala3
def scala3Versions = List(scala302, scala3)
def allScalaVersions = scala2Versions ++ scala3Versions

def scalajs = "1.5.1"
def scalajs = "1.7.1"
def scalajsBinaryVersion = "1"
def scalajsDom = "1.1.0"

Expand Down Expand Up @@ -65,6 +67,15 @@ def crossSetting[A](
case _ => Nil
}

def publishCrossVersion(scalaVersion: String): CrossVersion = {
// similar to `CrossVersion.binary`
// but for scala3 write both major and minor instead of just "3"
CrossVersion.partialVersion(scalaVersion) match {
case Some((major, minor)) => CrossVersion.constant(s"$major.$minor")
case None => throw new Exception(s"Invalid scala version: ${scalaVersion}")
}
}

inThisBuild(
List(
scalaVersion := scala213,
Expand Down Expand Up @@ -160,6 +171,7 @@ lazy val runtime = project
.settings(
sharedSettings,
moduleName := "mdoc-runtime",
crossVersion := publishCrossVersion(scalaVersion.value),
Compile / unmanagedSourceDirectories ++= multiScalaDirectories("runtime").value,
libraryDependencies ++= crossSetting(
scalaVersion.value,
Expand Down Expand Up @@ -194,6 +206,7 @@ lazy val cli = project
lazy val mdoc = project
.settings(
sharedSettings,
crossVersion := publishCrossVersion(scalaVersion.value),
Compile / unmanagedSourceDirectories ++= multiScalaDirectories("mdoc").value,
moduleName := "mdoc",
assembly / mainClass := Some("mdoc.Main"),
Expand Down Expand Up @@ -397,6 +410,7 @@ lazy val js = project
.in(file("mdoc-js"))
.settings(
sharedSettings,
crossVersion := publishCrossVersion(scalaVersion.value),
moduleName := "mdoc-js",
Compile / unmanagedSourceDirectories ++= multiScalaDirectories("js").value,
libraryDependencies ++= crossSetting(
Expand Down
7 changes: 6 additions & 1 deletion mdoc-sbt/src/main/scala/mdoc/MdocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ object MdocPlugin extends AutoPlugin {
}.evaluated,
libraryDependencies ++= {
val isJS = mdocJS.value.isDefined
val scalaBinVersion =
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((major, minor)) => s"_$major.$minor"
case None => throw new Exception(s"Invalid scala version: ${scalaVersion}")
}
if (mdocAutoDependency.value) {
val suffix = if (isJS) "-js" else ""
List("org.scalameta" %% s"mdoc$suffix" % BuildInfo.version)
List("org.scalameta" % s"mdoc${suffix}${scalaBinVersion}" % BuildInfo.version)
} else {
List()
}
Expand Down
2 changes: 1 addition & 1 deletion mdoc-sbt/src/sbt-test/sbt-mdoc/basic/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % sys.props("plugin.version"))
addSbtCoursier
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MarkdownCompiler(
report(vreporter, input, fileImports, run.runContext, edit)
}

class CollectionReporter extends dotty.tools.dotc.reporting.Reporter {
class CollectionReporter extends dotty.tools.dotc.reporting.Reporter with UniqueMessagePositions {
val allDiags = List.newBuilder[Diagnostic]

override def doReport(dia: Diagnostic)(using Context) =
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0")

libraryDependencies ++= List(
Expand Down
8 changes: 0 additions & 8 deletions tests/unit-js/src/test/scala/tests/js/JsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,6 @@ class JsSuite extends BaseMarkdownSuite {
|no-dom.md:3 (mdoc generated code)
| value scalajs is not a member of org
|def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = {
|
|
|error:
|no-dom.md:3 (mdoc generated code)
| (<error value scalajs is not a member of org>#dom.raw :
| <error value scalajs is not a member of org>
|) is not a valid type prefix, since it is not an immutable path
|def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = {
""".stripMargin
)
)
Expand Down

0 comments on commit d4e4b8c

Please sign in to comment.