Skip to content

Commit 3378b02

Browse files
committed
Skip tasks with Scala Native / Scala 3.0
- Update Scala Native Scala 3 version to 3.1.1
1 parent a41c06b commit 3378b02

File tree

2 files changed

+36
-52
lines changed

2 files changed

+36
-52
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ workflows:
159159
scala_version: 2.13.8
160160
- scalanative_job:
161161
name: native0.4_3
162-
scala_version: 3.1.0
162+
scala_version: 3.1.1

build.sbt

+35-51
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
140140
)
141141
.jsEnablePlugins(ScalaJSJUnitPlugin)
142142
.nativeSettings(
143-
crossScalaVersions := Seq("2.13.8", "2.12.15", "3.1.0"),
143+
crossScalaVersions := Seq("2.13.8", "2.12.15", "3.1.1"),
144144
mimaPreviousArtifacts := {
145145
// TODO remove this setting whien 2.0.2 released
146146
if (scalaBinaryVersion.value == "3") {
@@ -151,55 +151,39 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
151151
},
152152
// Scala Native cannot run forked tests
153153
Test / fork := false,
154-
Seq(Compile, Test).map { s =>
155-
s / sources := {
156-
CrossVersion.partialVersion(scalaVersion.value) match {
157-
case Some((3, 0)) =>
158-
Nil
159-
case _ =>
160-
(s / sources).value
161-
}
162-
}
163-
},
164-
libraryDependencies := {
165-
CrossVersion.partialVersion(scalaVersion.value) match {
166-
case Some((3, 0)) =>
167-
// scala-native does not support Scala 3.0.x
168-
Nil
169-
case _ =>
170-
libraryDependencies.value ++ Seq("org.scala-native" %%% "junit-runtime" % nativeVersion % Test)
171-
}
172-
},
173-
Compile / doc / scalacOptions --= {
174-
// TODO remove this workaround
175-
// https://github.com/scala-native/scala-native/issues/2503
176-
if (scalaBinaryVersion.value == "3") {
177-
(Compile / doc / scalacOptions).value.filter(_.contains("-Xplugin"))
178-
} else {
179-
Nil
180-
}
181-
},
182-
publish / skip := CrossVersion.partialVersion(scalaVersion.value) == Some((3, 0)),
183-
Test / scalacOptions ++= {
184-
if (CrossVersion.partialVersion(scalaVersion.value) != Some((3, 0))) {
185-
val log = streams.value.log
186-
val retrieveDir = baseDirectory.value / "scala-native-junit-plugin-jars"
187-
val lm = dependencyResolution.value
188-
val cp = lm
189-
.retrieve(
190-
"org.scala-native" % s"junit-plugin_${scalaVersion.value}" % nativeVersion,
191-
scalaModuleInfo = None,
192-
retrieveDir,
193-
log
194-
)
195-
.fold(w => throw w.resolveException, identity(_))
196-
val jarPath = cp
197-
.find(_.toString.contains("junit-plugin"))
198-
.getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar"))
199-
Seq(s"-Xplugin:$jarPath")
200-
} else {
201-
Nil
202-
}
154+
libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test,
155+
Test / scalacOptions += {
156+
val log = streams.value.log
157+
val retrieveDir = baseDirectory.value / "scala-native-junit-plugin-jars"
158+
val lm = dependencyResolution.value
159+
val cp = lm
160+
.retrieve(
161+
"org.scala-native" % s"junit-plugin_${scalaVersion.value}" % nativeVersion,
162+
scalaModuleInfo = None,
163+
retrieveDir,
164+
log
165+
)
166+
.fold(w => throw w.resolveException, identity(_))
167+
val jarPath = cp
168+
.find(_.toString.contains("junit-plugin"))
169+
.getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar"))
170+
s"-Xplugin:$jarPath"
203171
},
204-
Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v")
172+
Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v"),
173+
// Scala Native doesn't support Scala 3.0
174+
Compile / nativeLink := { if(isScala30(scalaVersion.value)) null else (Compile / nativeLink).value },
175+
Test / nativeLink := { if(isScala30(scalaVersion.value)) null else (Test / nativeLink).value },
176+
Test / test := { if(isScala30(scalaVersion.value)) {} else (Test / test).value },
177+
Compile / sources := { if(isScala30(scalaVersion.value)) Nil else (Compile / sources).value },
178+
Test / sources := { if(isScala30(scalaVersion.value)) Nil else (Test / sources).value },
179+
libraryDependencies := { if(isScala30(scalaVersion.value)) Nil else libraryDependencies.value },
180+
Test / scalacOptions := { if(isScala30(scalaVersion.value)) Nil else (Test / scalacOptions).value },
181+
publish / skip := { isScala30(scalaVersion.value) },
205182
)
183+
184+
def isScala30(scalaVersion: String) = {
185+
CrossVersion.partialVersion(scalaVersion) match {
186+
case Some((3, 0)) => true
187+
case _ => false
188+
}
189+
}

0 commit comments

Comments
 (0)