Skip to content

Commit 42abf8e

Browse files
authored
Support Scala Native - Scala 3 (#119)
* Support Scala Native - Scala 3 - Update Mill to 10.0.0 * Skip docJar in Scala 3 Scala Native
1 parent f7a45db commit 42abf8e

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

.github/workflows/actions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: ci
22

33
on:
44
push:
5+
branches:
6+
- master
7+
tags:
8+
- '*'
59
pull_request:
610
branches:
711
- master

build.sc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
2-
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.9:0.1.1`
2+
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.4`
33
import de.tobiasroeser.mill.vcs.version.VcsVersion
4-
import $ivy.`com.github.lolgab::mill-mima_mill0.9:0.0.4`
4+
import $ivy.`com.github.lolgab::mill-mima::0.0.9`
55
import com.github.lolgab.mill.mima._
66

77
val dottyVersions = sys.props.get("dottyVersion").toList
88

9-
val scalaVersions = "2.11.12" :: "2.12.13" :: "2.13.4" :: "3.0.0" :: dottyVersions
10-
val scala2Versions = scalaVersions.filter(_.startsWith("2."))
9+
val scala2VersionsAndDotty = "2.11.12" :: "2.12.13" :: "2.13.4" :: dottyVersions
10+
val scala30 = "3.0.0"
1111

1212
val scalaJSVersions = for {
13-
scalaV <- scalaVersions
13+
scalaV <- scala30 :: scala2VersionsAndDotty
1414
scalaJSV <- Seq("0.6.33", "1.5.1")
1515
if scalaV.startsWith("2.") || scalaJSV.startsWith("1.")
1616
} yield (scalaV, scalaJSV)
1717

1818
val scalaNativeVersions = for {
19-
scalaV <- scala2Versions
20-
scalaNativeV <- Seq("0.4.0")
19+
scalaV <- "3.1.0" :: scala2VersionsAndDotty
20+
scalaNativeV <- Seq("0.4.3")
2121
} yield (scalaV, scalaNativeV)
2222

2323
trait SourcecodeModule extends PublishModule with Mima {
@@ -32,10 +32,7 @@ trait SourcecodeModule extends PublishModule with Mima {
3232
organization = "com.lihaoyi",
3333
url = "https://github.com/lihaoyi/sourcecode",
3434
licenses = Seq(License.MIT),
35-
scm = SCM(
36-
"git://github.com/lihaoyi/sourcecode.git",
37-
"scm:git://github.com/lihaoyi/sourcecode.git"
38-
),
35+
versionControl = VersionControl.github(owner = "com-lihaoyi", repo = "sourcecode"),
3936
developers = Seq(
4037
Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")
4138
)
@@ -85,8 +82,7 @@ trait SourcecodeTestModule extends ScalaModule {
8582
}
8683

8784
object sourcecode extends Module {
88-
val dottyVersion = sys.props.get("dottyVersion")
89-
object jvm extends Cross[JvmSourcecodeModule](scalaVersions: _*)
85+
object jvm extends Cross[JvmSourcecodeModule](scala30 :: scala2VersionsAndDotty: _*)
9086
class JvmSourcecodeModule(val crossScalaVersion: String)
9187
extends SourcecodeMainModule with ScalaModule with SourcecodeModule {
9288

@@ -119,6 +115,15 @@ object sourcecode extends Module {
119115

120116
def scalaNativeVersion = crossScalaNativeVersion
121117

118+
override def docJar =
119+
if (crossScalaVersion.startsWith("2.")) super.docJar
120+
else T {
121+
val outDir = T.ctx().dest
122+
val javadocDir = outDir / "javadoc"
123+
os.makeDir.all(javadocDir)
124+
mill.api.Result.Success(mill.modules.Jvm.createJar(Agg(javadocDir))(outDir))
125+
}
126+
122127
object test extends SourcecodeTestModule with ScalaNativeModule{
123128
def scalaVersion = crossScalaVersion
124129
def scalaNativeVersion = crossScalaNativeVersion

mill

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
# This is a wrapper script, that automatically download mill from GitHub release pages
44
# You can give the required mill version with MILL_VERSION env variable
55
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
6-
DEFAULT_MILL_VERSION=0.9.6-61-bd7927
6+
DEFAULT_MILL_VERSION=0.10.0
77

88
set -e
99

1010
if [ -z "$MILL_VERSION" ] ; then
1111
if [ -f ".mill-version" ] ; then
1212
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
13-
elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then
13+
elif [ -f "mill" ] && [ "$0" != "mill" ] ; then
1414
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2)
1515
else
1616
MILL_VERSION=$DEFAULT_MILL_VERSION
@@ -28,13 +28,14 @@ version_remainder="$MILL_VERSION"
2828
MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
2929
MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}"
3030

31-
if [ ! -x "$MILL_EXEC_PATH" ] ; then
32-
mkdir -p $MILL_DOWNLOAD_PATH
31+
if [ ! -s "$MILL_EXEC_PATH" ] ; then
32+
mkdir -p "$MILL_DOWNLOAD_PATH"
3333
if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then
3434
ASSEMBLY="-assembly"
3535
fi
3636
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
37-
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}"
37+
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
38+
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}"
3839
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL"
3940
chmod +x "$DOWNLOAD_FILE"
4041
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"

0 commit comments

Comments
 (0)