-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cross compile with Scala JS and Scala Native
- Loading branch information
1 parent
26277c1
commit de95087
Showing
4 changed files
with
121 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,61 @@ | ||
val scala2version = "2.13.8" | ||
val scala3version = "3.2.0" | ||
|
||
// compiling | ||
|
||
val commonSettings = Seq( | ||
scalaVersion := scala3version, | ||
crossScalaVersions := Seq(scala2version, scala3version), | ||
scalacOptions ++= { | ||
CrossVersion.partialVersion(scalaVersion.value) match { | ||
case Some((2, 13)) => Seq("-deprecation", "-feature", "-Xsource:3", "-P:kind-projector:underscore-placeholders") | ||
case Some((3, 2)) => Seq("-explain", "-rewrite", "-source", "3.2-migration", "-Ykind-projector:underscores") | ||
case _ => Seq.empty | ||
} | ||
}, | ||
libraryDependencies ++= { | ||
CrossVersion.partialVersion(scalaVersion.value) match { | ||
case Some((2, 13)) => | ||
Seq( | ||
compilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full) | ||
) | ||
case _ => Seq.empty | ||
} | ||
}, | ||
libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test, | ||
scalafmtOnCompile := true | ||
) | ||
|
||
// publishing | ||
|
||
val publishSettings = Seq( | ||
organization := "com.kubuszok", | ||
homepage := Some(url("https://kubuszok.com")), | ||
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), | ||
scmInfo := Some( | ||
ScmInfo(url("https://github.com/MateuszKubuszok/pipez"), "scm:git@github.com/MateuszKubuszok/pipez.git") | ||
), | ||
publishTo := { | ||
val nexus = "https://oss.sonatype.org/" | ||
if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots") | ||
else Some("releases" at nexus + "service/local/staging/deploy/maven2") | ||
}, | ||
Test / publishArtifact := false, | ||
pomIncludeRepository := { _ => | ||
false | ||
}, | ||
pomExtra := | ||
<developers> | ||
<developer> | ||
<id>MateuszKubuszok</id> | ||
<name>Mateusz Kubuszok</name> | ||
<url>https://github.com/MateuszKubuszok</url> | ||
</developer> | ||
</developers> | ||
) | ||
val noPublishSettings = Seq( | ||
publish / skip := true, | ||
publishArtifact := false | ||
) | ||
import commandmatrix.extra._ | ||
import Settings._ | ||
|
||
// 2.13 only since apparently my way of doing Java Beans (@BeanProperty) have slightly different behavior in 3.x | ||
val testCases = project | ||
val testCases = projectMatrix | ||
.in(file("testcases")) | ||
.settings( | ||
name := "testcases", | ||
scalaVersion := scala2version, | ||
crossScalaVersions := Seq(scala2version), | ||
scalacOptions ++= Seq("-deprecation", "-feature", "-Xsource:3") | ||
.allVariations( | ||
List(scala2_13version), | ||
List(VirtualAxis.jvm, VirtualAxis.js, VirtualAxis.native) | ||
) | ||
.settings(name := "testcases") | ||
.settings(commonSettings) | ||
.settings(publishSettings) | ||
.settings(noPublishSettings) | ||
|
||
val pipez = project | ||
val pipez = projectMatrix | ||
.in(file("pipez")) | ||
.allVariations( | ||
List(scala2_13version, scala3version), | ||
List(VirtualAxis.jvm, VirtualAxis.js, VirtualAxis.native) | ||
) | ||
.enablePlugins(GitVersioning) | ||
.settings(name := "pipez") | ||
.settings(commonSettings: _*) | ||
.settings(publishSettings: _*) | ||
.dependsOn(testCases % "test->compile") | ||
.settings( | ||
name := "pipez", | ||
libraryDependencies ++= { | ||
CrossVersion.partialVersion(scalaVersion.value) match { | ||
case Some((2, 13)) => Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value) | ||
case _ => Seq.empty | ||
} | ||
} | ||
excludeDependencies ++= Seq( | ||
ExclusionRule().withName("testcases_3"), | ||
ExclusionRule().withName("testcases_sjs1_3"), | ||
ExclusionRule().withName("testcases_native0.4_3") | ||
) | ||
) | ||
.settings(commonSettings) | ||
.settings(publishSettings) | ||
.dependsOn(testCases % "test->compile") | ||
|
||
val pipezDsl = project | ||
val pipezDsl = projectMatrix | ||
.in(file("pipez-dsl")) | ||
.allVariations( | ||
List(scala2_13version, scala3version), | ||
List(VirtualAxis.jvm, VirtualAxis.js, VirtualAxis.native) | ||
) | ||
.enablePlugins(GitVersioning) | ||
.settings(name := "pipez-dsl") | ||
.settings(commonSettings: _*) | ||
.settings(publishSettings: _*) | ||
.dependsOn(testCases % "compile->test", pipez) | ||
.settings( | ||
name := "pipez-dsl" | ||
excludeDependencies ++= Seq( | ||
ExclusionRule().withName("testcases_3"), | ||
ExclusionRule().withName("testcases_sjs1_3"), | ||
ExclusionRule().withName("testcases_native0.4_3") | ||
) | ||
) | ||
.settings(commonSettings) | ||
.dependsOn(testCases % "test->compile", pipez) | ||
|
||
val root = project | ||
.in(file(".")) | ||
.enablePlugins(GitVersioning) | ||
.settings( | ||
name := "pipez-build", | ||
) | ||
.settings(commonSettings) | ||
.settings(publishSettings) | ||
.settings(noPublishSettings) | ||
.aggregate(pipez, pipezDsl) | ||
|
||
addCommandAlias("use-213", s"++ $scala2version") | ||
addCommandAlias("use-3", s"++ $scala3version") | ||
.settings(name := "pipez-build") | ||
.settings(commonSettings: _*) | ||
.settings(publishSettings: _*) | ||
.settings(noPublishSettings: _*) | ||
.aggregate(pipez.projectRefs ++ pipezDsl.projectRefs: _*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import sbt._ | ||
import sbt.Keys._ | ||
import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ | ||
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ | ||
import commandmatrix.extra._ | ||
|
||
object Settings { | ||
|
||
val scala2_13version = "2.13.8" | ||
val scala3version = "3.2.0" | ||
|
||
// compiling | ||
|
||
val commonSettings = Seq( | ||
scalacOptions ++= { | ||
CrossVersion.partialVersion(scalaVersion.value) match { | ||
case Some((2, 13)) => Seq("-deprecation", "-feature", "-Xsource:3", "-P:kind-projector:underscore-placeholders") | ||
case Some((3, 2)) => Seq("-explain", "-rewrite", "-source", "3.2-migration", "-Ykind-projector:underscores") | ||
case _ => Seq.empty | ||
} | ||
}, | ||
libraryDependencies ++= { | ||
CrossVersion.partialVersion(scalaVersion.value) match { | ||
case Some((2, 13)) => | ||
Seq( | ||
"org.scala-lang" % "scala-reflect" % scalaVersion.value, | ||
compilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full) | ||
) | ||
case _ => Seq.empty | ||
} | ||
}, | ||
libraryDependencies += "org.scalameta" %%% "munit" % "1.0.0-M6" % Test, | ||
scalafmtOnCompile := true | ||
) | ||
|
||
// publishing | ||
|
||
val publishSettings = Seq( | ||
organization := "com.kubuszok", | ||
homepage := Some(url("https://kubuszok.com")), | ||
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), | ||
scmInfo := Some( | ||
ScmInfo(url("https://github.com/MateuszKubuszok/pipez"), "scm:git@github.com/MateuszKubuszok/pipez.git") | ||
), | ||
publishTo := { | ||
val nexus = "https://oss.sonatype.org/" | ||
if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots") | ||
else Some("releases" at nexus + "service/local/staging/deploy/maven2") | ||
}, | ||
Test / publishArtifact := false, | ||
pomIncludeRepository := { _ => | ||
false | ||
}, | ||
pomExtra := | ||
<developers> | ||
<developer> | ||
<id>MateuszKubuszok</id> | ||
<name>Mateusz Kubuszok</name> | ||
<url>https://github.com/MateuszKubuszok</url> | ||
</developer> | ||
</developers> | ||
) | ||
|
||
val noPublishSettings = Seq( | ||
publish / skip := true, | ||
publishArtifact := false | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") | ||
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.0") | ||
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0") | ||
addSbtPlugin("com.indoorvivants" % "sbt-commandmatrix" % "0.0.5") | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.11.0") | ||
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7") |