Skip to content

Commit

Permalink
Cross for Scala.js, freshen build
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Aug 9, 2021
1 parent 4cd6a98 commit 9174744
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ jobs:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
- uses: coursier/cache-action@v3
- run: sbt clean headerCheck +test
- run: sbt clean sourceposJVM/headerCheck +test
94 changes: 55 additions & 39 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,52 +1,68 @@

// Our Scala versions.
lazy val `scala-2.12` = "2.12.12"
lazy val `scala-2.13` = "2.13.5"
lazy val `scala-3.0` = "3.0.0"
lazy val `scala-2.12` = "2.12.14"
lazy val `scala-2.13` = "2.13.6"
lazy val `scala-3.0` = "3.0.1"

// Publishing
name := "sourcepos"
organization := "org.tpolecat"
licenses ++= Seq(("MIT", url("http://opensource.org/licenses/MIT")))
homepage := Some(url("https://github.com/tpolecat/sourcepos"))
developers := List(
ThisBuild / organization := "org.tpolecat"
ThisBuild / licenses ++= Seq(("MIT", url("http://opensource.org/licenses/MIT")))
ThisBuild / homepage := Some(url("https://github.com/tpolecat/sourcepos"))
ThisBuild / developers := List(
Developer("tpolecat", "Rob Norris", "[email protected]", url("http://www.tpolecat.org"))
)

// Headers
headerMappings := headerMappings.value + (HeaderFileType.scala -> HeaderCommentStyle.cppStyleLineComment)
headerLicense := Some(HeaderLicense.Custom(
"""|Copyright (c) 2020-2021 by Rob Norris
|This software is licensed under the MIT License (MIT).
|For more information see LICENSE or https://opensource.org/licenses/MIT
|""".stripMargin
// Compilation
ThisBuild / scalaVersion := `scala-2.13`
ThisBuild / crossScalaVersions := Seq(`scala-2.12`, `scala-2.13`, `scala-3.0`)

lazy val root = project
.in(file("."))
.enablePlugins(NoPublishPlugin)
.settings(
Compile / unmanagedSourceDirectories := Seq.empty,
Test / unmanagedSourceDirectories := Seq.empty,
)
)
.aggregate(sourcepos.jvm, sourcepos.js)

// Compilation
scalaVersion := `scala-2.13`
crossScalaVersions := Seq(`scala-2.12`, `scala-2.13`, `scala-3.0`)
Compile / doc / scalacOptions --= Seq("-Xfatal-warnings")
Compile / doc / scalacOptions ++= Seq(
"-groups",
"-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath,
"-doc-source-url", "https://github.com/tpolecat/sourcepos/blob/v" + version.value + "€{FILE_PATH}.scala",
)
lazy val sourcepos = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Pure)
.in(file("."))
.enablePlugins(AutomateHeaderPlugin)
.settings(
name := "sourcepos",

// Headers
headerMappings := headerMappings.value + (HeaderFileType.scala -> HeaderCommentStyle.cppStyleLineComment),
headerLicense := Some(HeaderLicense.Custom(
"""|Copyright (c) 2020-2021 by Rob Norris
|This software is licensed under the MIT License (MIT).
|For more information see LICENSE or https://opensource.org/licenses/MIT
|""".stripMargin
)
),

// MUnit
libraryDependencies += "org.scalameta" %% "munit" % "0.7.26" % Test
testFrameworks += new TestFramework("munit.Framework")
// Compilation
Compile / doc / scalacOptions --= Seq("-Xfatal-warnings"),
Compile / doc / scalacOptions ++= Seq(
"-groups",
"-sourcepath", (LocalRootProject / baseDirectory).value.getAbsolutePath,
"-doc-source-url", "https://github.com/tpolecat/sourcepos/blob/v" + version.value + "€{FILE_PATH}.scala",
),

// Scala 2 needs scala-reflect
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value).filterNot(_ => scalaVersion.value.startsWith("3."))
// MUnit
libraryDependencies += "org.scalameta" %%% "munit" % "0.7.28" % Test,
testFrameworks += new TestFramework("munit.Framework"),

// dottydoc really doesn't work at all right now
Compile / doc / sources := {
val old = (Compile / doc / sources).value
if (scalaVersion.value.startsWith("3."))
Seq()
else
old
}
// Scala 2 needs scala-reflect
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value).filterNot(_ => scalaVersion.value.startsWith("3.")),

enablePlugins(AutomateHeaderPlugin)
// dottydoc really doesn't work at all right now
Compile / doc / sources := {
val old = (Compile / doc / sources).value
if (scalaVersion.value.startsWith("3."))
Seq()
else
old
}
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.2
sbt.version=1.5.5
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0")
addSbtPlugin("io.chrisdavenport" % "sbt-no-publish" % "0.1.0")
2 changes: 1 addition & 1 deletion src/test/scala/Example.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 by Rob Norris
// Copyright (c) 2020-2021 by Rob Norris
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/Test.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 by Rob Norris
// Copyright (c) 2020-2021 by Rob Norris
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

Expand Down

0 comments on commit 9174744

Please sign in to comment.