Skip to content
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

Cross for Scala.js and freshen build #7

Merged
merged 1 commit into from
Aug 10, 2021
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
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", "rob_norris@mac.com", 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