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

Scala-Native 0.5.0 support #154

Merged
merged 5 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Run tests
run: ./mill -i all __.publishArtifacts __.test
run: ./mill -i __.publishArtifacts + __.test.run

check-binary-compatibility:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.12
0.11.7-29-f2e220
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,13 @@ in its `.toString` method.
Version History
===============

master
------

* Support for Scala-Native 0.5.0
* Minimum version of Scala 2 raised to 2.12.x
* Minimum version of Scala 3 raised to 3.3.1

0.3.1
-----

Expand Down
104 changes: 22 additions & 82 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ import $ivy.`com.github.lolgab::mill-mima::0.1.0`
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
import de.tobiasroeser.mill.vcs.version.VcsVersion
import com.github.lolgab.mill.mima._
import mill.scalalib.api.Util.isScala3

val dottyCommunityBuildVersion = sys.props.get("dottyVersion").toList

val scalaVersions =
"2.11.12" :: "2.12.16" :: "2.13.8" :: "3.1.3" :: dottyCommunityBuildVersion

val scalaJSVersions = scalaVersions.map((_, "1.10.1"))
val scalaNativeVersions = scalaVersions.map((_, "0.4.5"))
"2.12.16" :: "2.13.8" :: "3.3.1" :: dottyCommunityBuildVersion

trait MimaCheck extends Mima {
def mimaPreviousVersions = Seq("0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.3.0", "0.3.1")
Expand All @@ -28,7 +24,7 @@ trait SourcecodeModule extends PublishModule with MimaCheck {
// Temporary until the next version of Mima gets released with
// https://github.com/lightbend/mima/issues/693 included in the release.
def mimaPreviousArtifacts =
if(isScala3(crossScalaVersion)) Agg.empty[Dep] else super.mimaPreviousArtifacts()
if(crossScalaVersion.startsWith("3.")) Agg.empty[Dep] else super.mimaPreviousArtifacts()
Copy link
Member

Choose a reason for hiding this comment

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

isScala3 still exists but is inside ZincWorkerUtil now I believe

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed


def pomSettings = PomSettings(
description = artifactName(),
Expand All @@ -41,98 +37,42 @@ trait SourcecodeModule extends PublishModule with MimaCheck {
)
)
}
trait SourcecodeMainModule extends CrossScalaModule {
def millSourcePath = super.millSourcePath / offset

def offset: os.RelPath = os.rel

trait SourcecodeMainModule extends CrossScalaModule with PlatformScalaModule {
def compileIvyDeps =
if (crossScalaVersion.startsWith("2")) Agg(
ivy"org.scala-lang:scala-reflect:${crossScalaVersion}",
ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
)
else Agg.empty[Dep]

def sources = T.sources(
super.sources()
.flatMap(source =>
Seq(
PathRef(source.path / os.up / source.path.last),
PathRef(source.path / os.up / os.up / source.path.last)
)
)
)
}

object sourcecode extends Module {
object jvm extends Cross[JvmSourcecodeModule](scalaVersions)
trait JvmSourcecodeModule extends SourcecodeMainModule with ScalaModule with SourcecodeModule {

trait SourcecodeTestModule extends ScalaModule {
def crossScalaVersion: String

def offset: os.RelPath = os.rel
def millSourcePath = super.millSourcePath / os.up

def sources = T.sources(
super.sources()
.++(CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" ))
.flatMap(source =>
Seq(
PathRef(source.path / os.up / "test" / source.path.last),
PathRef(source.path / os.up / os.up / "test" / source.path.last)
)
)
.distinct
)
}
object test extends ScalaTests{

object sourcecode extends Module {
object jvm extends Cross[JvmSourcecodeModule](scalaVersions: _*)
class JvmSourcecodeModule(val crossScalaVersion: String)
extends SourcecodeMainModule with ScalaModule with SourcecodeModule {

object test extends SourcecodeTestModule{
def scalaVersion = crossScalaVersion
def moduleDeps = Seq(JvmSourcecodeModule.this)
val crossScalaVersion = JvmSourcecodeModule.this.crossScalaVersion
def testFramework = ""
}
}

object js extends Cross[JsSourcecodeModule](scalaJSVersions: _*)
class JsSourcecodeModule(val crossScalaVersion: String, crossJSVersion: String)
extends SourcecodeMainModule with ScalaJSModule with SourcecodeModule {
def offset = os.up

def scalaJSVersion = crossJSVersion
object test extends SourcecodeTestModule with ScalaJSModule{
def scalaVersion = crossScalaVersion
def scalaJSVersion = crossJSVersion
def offset = os.up
def moduleDeps = Seq(JsSourcecodeModule.this)
val crossScalaVersion = JsSourcecodeModule.this.crossScalaVersion
object js extends Cross[JsSourcecodeModule](scalaVersions)
trait JsSourcecodeModule extends SourcecodeMainModule with ScalaJSModule with SourcecodeModule {

def scalaJSVersion = "1.12.0"
object test extends ScalaJSTests{
def testFramework = ""
}
}

object native extends Cross[NativeSourcecodeModule](scalaNativeVersions: _*)
class NativeSourcecodeModule(val crossScalaVersion: String, crossScalaNativeVersion: String)
extends SourcecodeMainModule with ScalaNativeModule with SourcecodeModule {
def offset = os.up

def scalaNativeVersion = crossScalaNativeVersion

override def docJar =
if (crossScalaVersion.startsWith("2.")) super.docJar
else T {
val outDir = T.ctx().dest
val javadocDir = outDir / "javadoc"
os.makeDir.all(javadocDir)
mill.api.Result.Success(mill.modules.Jvm.createJar(Agg(javadocDir))(outDir))
}

object test extends SourcecodeTestModule with ScalaNativeModule{
def scalaVersion = crossScalaVersion
def scalaNativeVersion = crossScalaNativeVersion
def offset = os.up
def moduleDeps = Seq(NativeSourcecodeModule.this)
val crossScalaVersion = NativeSourcecodeModule.this.crossScalaVersion
object native extends Cross[NativeSourcecodeModule](scalaVersions)
trait NativeSourcecodeModule extends SourcecodeMainModule with ScalaNativeModule with SourcecodeModule {

def scalaNativeVersion = "0.5.0"
object test extends ScalaNativeTests{
// stub to make use of test plumbing but not running a test suite
Copy link
Member

Choose a reason for hiding this comment

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

Why can't we run tests on Scala Native?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lolgab sourcecode doesnt use a test framework, it just runs through the asserts starting from def main. But the build level plumbing for nested test modules w.r.t. cross version and cross platform modules is very handy, so I'm abusing it a bit

def mainClass = Some("sourcecode.Main")
def testFramework = ""
}
}
}
Loading