forked from scala/scala-xml
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
158 lines (145 loc) · 6.36 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
publish / skip := true // root project
ThisBuild / startYear := Some(2002)
ThisBuild / licenses += (("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))
// because it doesn't declare it itself
ThisBuild / libraryDependencySchemes += "org.scala-js" %% "scalajs-library" % "semver-spec"
lazy val configSettings: Seq[Setting[_]] = Seq(
unmanagedSourceDirectories ++= {
unmanagedSourceDirectories.value.flatMap { dir =>
val sv = scalaVersion.value
Seq(
CrossVersion.partialVersion(sv) match {
case Some((major, minor)) if major > 2 || (major == 2 && minor >= 13) => file(dir.getPath ++ "-2.13+")
case _ => file(dir.getPath ++ "-2.13-")
},
CrossVersion.partialVersion(sv) match {
case Some((2, _)) => file(dir.getPath ++ "-2.x")
case _ => file(dir.getPath ++ "-3.x")
}
)
}
}
)
lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Full)
.in(file("."))
.settings(ScalaModulePlugin.scalaModuleSettings)
.jvmSettings(ScalaModulePlugin.scalaModuleOsgiSettings)
.settings(
name := "scala-xml",
scalaModuleAutomaticModuleName := Some("scala.xml"),
crossScalaVersions := Seq("2.13.8", "2.12.16", "3.1.3"),
scalaVersion := "2.12.16",
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Seq("-language:Scala2")
case _ =>
// Compiler team advised avoiding the -Xsource:3 option for releases.
// The output with -Xsource:3 should be periodically checked, though.
Seq("-deprecation:false", "-feature", "-Xlint:-stars-align,-nullary-unit,_")
}),
Test / scalacOptions += "-Xxml:coalescing",
headerLicense := Some(HeaderLicense.Custom(
s"""|Scala (https://www.scala-lang.org)
|
|Copyright EPFL and Lightbend, Inc.
|
|Licensed under Apache License 2.0
|(http://www.apache.org/licenses/LICENSE-2.0).
|
|See the NOTICE file distributed with this work for
|additional information regarding copyright ownership.
|""".stripMargin)),
// should be reverted to Compatibility.BinaryAndSourceCompatible after 2.2.0 is released
versionPolicyIntention := Compatibility.None,
// Note: See discussion on non-JVM Mima in https://github.com/scala/scala-xml/pull/517
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
Seq(
// afaict this is just a JDK 8 vs 16 difference, producing a false positive when
// we compare classes built on JDK 16 (which we only do on CI, not at release time)
// to previous-version artifacts that were built on 8. see scala/scala-xml#501
exclude[DirectMissingMethodProblem]("scala.xml.include.sax.XIncluder.declaration"),
// necessitated by the switch from DefaultHandler to DefaultHandler2 in FactoryAdapter:
exclude[MissingTypesProblem]("scala.xml.parsing.FactoryAdapter"), // see #549
// necessitated by the introduction of new abstract methods in FactoryAdapter:
exclude[ReversedMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createComment"), // see #549
exclude[ReversedMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createPCData") // see #558
)
},
// Mima signature checking stopped working after 3.0.2 upgrade, see #557
mimaReportSignatureProblems := (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => false
case _ => true
}),
apiMappings ++= scalaInstance.value.libraryJars.filter { file =>
file.getName.startsWith("scala-library") && file.getName.endsWith(".jar")
}.map { libraryJar =>
libraryJar ->
url(s"http://www.scala-lang.org/api/${scalaVersion.value}/")
}.toMap ++ {
// http://stackoverflow.com/questions/16934488
Option(System.getProperty("sun.boot.class.path")).flatMap { classPath =>
classPath.split(java.io.File.pathSeparator).find(_.endsWith(java.io.File.separator + "rt.jar"))
}.map { jarPath =>
Map(
file(jarPath)
-> url("http://docs.oracle.com/javase/8/docs/api")
)
} getOrElse {
// If everything fails, jam in Java 11 modules.
Map(
file("/modules/java.base")
-> url("https://docs.oracle.com/en/java/javase/11/docs/api/java.base"),
file("/modules/java.xml")
-> url("https://docs.oracle.com/en/java/javase/11/docs/api/java.xml")
)
}
}
)
.settings(
inConfig(Compile)(configSettings) ++ inConfig(Test)(configSettings)
)
.jvmSettings(
OsgiKeys.exportPackage := Seq(s"scala.xml.*;version=${version.value}"),
libraryDependencies += "junit" % "junit" % "4.13.2" % Test,
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test,
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.12.0" % Test,
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Seq()
case _ =>
Seq("org.scala-lang" % "scala-compiler" % scalaVersion.value % Test)
}),
)
.jsSettings(
// Scala.js cannot run forked tests
Test / fork := false
)
.jsEnablePlugins(ScalaJSJUnitPlugin)
.nativeSettings(
// Scala Native cannot run forked tests
Test / fork := false,
libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test,
Test / scalacOptions += {
val log = streams.value.log
val retrieveDir = baseDirectory.value / "scala-native-junit-plugin-jars"
val lm = dependencyResolution.value
val cp = lm
.retrieve(
"org.scala-native" % s"junit-plugin_${scalaVersion.value}" % nativeVersion,
scalaModuleInfo = None,
retrieveDir,
log
)
.fold(w => throw w.resolveException, identity(_))
val jarPath = cp
.find(_.toString.contains("junit-plugin"))
.getOrElse(throw new Exception("Can't find Scala Native junit-plugin jar"))
s"-Xplugin:$jarPath"
},
Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v"),
)