Skip to content

Commit 975b95b

Browse files
committed
Build definitions from main branch
Unchanged, from revision 82d76cf.
1 parent a2d6d9a commit 975b95b

File tree

5 files changed

+170
-36
lines changed

5 files changed

+170
-36
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
test:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
java: [8, 11, 17]
13+
scala: [2.12.x, 2.13.x, 3.x]
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- uses: actions/setup-java@v3
20+
with:
21+
distribution: temurin
22+
java-version: ${{matrix.java}}
23+
cache: sbt
24+
- name: Test
25+
run: sbt ++${{matrix.scala}} test headerCheck versionPolicyCheck package

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release
2+
on:
3+
push:
4+
tags: ["*"]
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
with:
11+
fetch-depth: 0
12+
- uses: actions/setup-java@v2
13+
with:
14+
distribution: temurin
15+
java-version: 8
16+
- run: sbt versionCheck ci-release
17+
env:
18+
PGP_PASSPHRASE: ${{secrets.PGP_PASSPHRASE}}
19+
PGP_SECRET: ${{secrets.PGP_SECRET}}
20+
SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}}
21+
SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}}

build.sbt

Lines changed: 117 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,91 @@
11
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
22

3-
lazy val xml = crossProject(JSPlatform, JVMPlatform)
3+
publish / skip := true // root project
4+
5+
ThisBuild / startYear := Some(2002)
6+
ThisBuild / licenses += (("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))
7+
8+
// because it doesn't declare it itself
9+
ThisBuild / libraryDependencySchemes += "org.scala-js" %% "scalajs-library" % "semver-spec"
10+
ThisBuild / apiURL := Some(url("https://javadoc.io/doc/org.scala-lang.modules/scala-xml_2.13/"))
11+
12+
lazy val configSettings: Seq[Setting[?]] = Seq(
13+
unmanagedSourceDirectories ++= {
14+
unmanagedSourceDirectories.value.flatMap { dir =>
15+
def forVersion(version: String): File = file(dir.getPath ++ "-" ++ version)
16+
CrossVersion.partialVersion(scalaVersion.value) match {
17+
case Some((3, _)) => Seq(forVersion("3"), forVersion("2.13+"))
18+
case Some((2, minor)) =>
19+
Seq(forVersion("2")) ++ (minor match {
20+
case 13 => Seq(forVersion("2.13"), forVersion("2.13+"))
21+
case 12 => Seq(forVersion("2.12"))
22+
case _ => Seq()
23+
})
24+
case _ => Seq()
25+
}
26+
}
27+
}
28+
)
29+
30+
lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
431
.withoutSuffixFor(JVMPlatform)
532
.crossType(CrossType.Full)
633
.in(file("."))
734
.settings(ScalaModulePlugin.scalaModuleSettings)
8-
.jvmSettings(ScalaModulePlugin.scalaModuleSettingsJVM)
35+
.jvmSettings(ScalaModulePlugin.scalaModuleOsgiSettings)
936
.settings(
1037
name := "scala-xml",
38+
scalaModuleAutomaticModuleName := Some("scala.xml"),
39+
crossScalaVersions := Seq("2.13.11", "2.12.18", "3.3.0"),
40+
scalaVersion := "2.12.18",
1141

12-
// Compiler team advised avoiding the -Xfuture option for releases.
13-
// The output with -Xfuture should be periodically checked, though.
14-
scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_".split("\\s+").to[Seq],
15-
scalacOptions in Test += "-Xxml:coalescing",
42+
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
43+
case Some((3, _)) =>
44+
Seq("-language:Scala2")
45+
case _ =>
46+
// Compiler team advised avoiding the -Xsource:3 option for releases.
47+
// The output with -Xsource:3 should be periodically checked, though.
48+
Seq("-deprecation:false", "-feature", "-Xlint:-stars-align,-nullary-unit,_")
49+
}),
1650

17-
scalaModuleMimaPreviousVersion := {
18-
if (System.getenv("SCALAJS_VERSION") == "1.0.1") None
19-
else Some("1.2.0")
20-
},
51+
Test / scalacOptions += "-Xxml:coalescing",
2152

22-
unmanagedSourceDirectories in Compile ++= {
23-
(unmanagedSourceDirectories in Compile).value.map { dir =>
24-
val sv = scalaVersion.value
25-
CrossVersion.partialVersion(sv) match {
26-
case Some((2, 13)) => file(dir.getPath ++ "-2.13")
27-
case _ => file(dir.getPath ++ "-2.11-2.12")
28-
}
29-
}
30-
},
53+
headerLicense := Some(HeaderLicense.Custom(
54+
s"""|Scala (https://www.scala-lang.org)
55+
|
56+
|Copyright EPFL and Lightbend, Inc.
57+
|
58+
|Licensed under Apache License 2.0
59+
|(http://www.apache.org/licenses/LICENSE-2.0).
60+
|
61+
|See the NOTICE file distributed with this work for
62+
|additional information regarding copyright ownership.
63+
|""".stripMargin)),
3164

32-
apiURL := Some(
33-
url(s"""https://scala.github.io/scala-xml/api/${"-.*".r.replaceAllIn(version.value, "")}/""")
34-
),
65+
versionPolicyIntention := Compatibility.BinaryCompatible,
66+
// Note: See discussion on non-JVM Mima in https://github.com/scala/scala-xml/pull/517
67+
mimaBinaryIssueFilters ++= {
68+
//import com.typesafe.tools.mima.core.{}
69+
//import com.typesafe.tools.mima.core.ProblemFilters
70+
Seq( // exclusions for all Scala versions
71+
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
72+
case Some((3, _)) => Seq( // Scala 3-specific exclusions
73+
)
74+
case Some((2, minor)) => Seq( // Scala 2-specific exclusions
75+
) ++ (minor match {
76+
case 13 => Seq( // Scala 2.13-specific exclusions
77+
)
78+
case 12 => Seq( // Scala 2.12-specific exclusions
79+
)
80+
})
81+
case _ => Seq()
82+
})
83+
},
84+
// Mima signature checking stopped working after 3.0.2 upgrade, see #557
85+
mimaReportSignatureProblems := (CrossVersion.partialVersion(scalaVersion.value) match {
86+
case Some((3, _)) => false
87+
case _ => true
88+
}),
3589

3690
apiMappings ++= scalaInstance.value.libraryJars.filter { file =>
3791
file.getName.startsWith("scala-library") && file.getName.endsWith(".jar")
@@ -47,7 +101,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform)
47101
file(jarPath)
48102
-> url("http://docs.oracle.com/javase/8/docs/api")
49103
)
50-
} getOrElse {
104+
}.getOrElse {
51105
// If everything fails, jam in Java 11 modules.
52106
Map(
53107
file("/modules/java.base")
@@ -58,16 +112,50 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform)
58112
}
59113
}
60114
)
115+
.settings(
116+
inConfig(Compile)(configSettings) ++ inConfig(Test)(configSettings)
117+
)
61118
.jvmSettings(
62119
OsgiKeys.exportPackage := Seq(s"scala.xml.*;version=${version.value}"),
63120

64-
libraryDependencies += "junit" % "junit" % "4.13" % "test",
65-
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
66-
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.9" % "test",
67-
libraryDependencies += ("org.scala-lang" % "scala-compiler" % scalaVersion.value % "test").exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}")
121+
libraryDependencies += "junit" % "junit" % "4.13.2" % Test,
122+
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test,
123+
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.12.0" % Test,
124+
libraryDependencies += "xerces" % "xercesImpl" % "2.12.2" % Test,
125+
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
126+
case Some((3, _)) =>
127+
Seq()
128+
case _ =>
129+
Seq("org.scala-lang" % "scala-compiler" % scalaVersion.value % Test)
130+
}),
68131
)
69132
.jsSettings(
70133
// Scala.js cannot run forked tests
71-
fork in Test := false
134+
Test / fork := false
135+
)
136+
.jsEnablePlugins(ScalaJSJUnitPlugin)
137+
.nativeSettings(
138+
versionPolicyCheck / skip := true,
139+
versionCheck / skip := true,
140+
// Scala Native cannot run forked tests
141+
Test / fork := false,
142+
libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test,
143+
Test / scalacOptions += {
144+
val log = streams.value.log
145+
val retrieveDir = baseDirectory.value / "scala-native-junit-plugin-jars"
146+
val lm = dependencyResolution.value
147+
val cp = lm
148+
.retrieve(
149+
"org.scala-native" % s"junit-plugin_${scalaVersion.value}" % nativeVersion,
150+
scalaModuleInfo = None,
151+
retrieveDir,
152+
log
153+
)
154+
.fold(w => throw w.resolveException, identity)
155+
val jarPath = cp
156+
.find(_.toString.contains("junit-plugin"))
157+
.getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar"))
158+
s"-Xplugin:$jarPath"
159+
},
160+
Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v"),
72161
)
73-
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.3.13
1+
sbt.version=1.9.2

project/plugins.sbt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
val scalaJSVersion =
2-
Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("0.6.33")
3-
4-
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.1.3")
5-
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
6-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
1+
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.1.0")
2+
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
3+
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
4+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2")
5+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.14")
6+
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")

0 commit comments

Comments
 (0)