1
1
import sbtcrossproject .CrossPlugin .autoImport .{crossProject , CrossType }
2
2
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 )
4
31
.withoutSuffixFor(JVMPlatform )
5
32
.crossType(CrossType .Full )
6
33
.in(file(" ." ))
7
34
.settings(ScalaModulePlugin .scalaModuleSettings)
8
- .jvmSettings(ScalaModulePlugin .scalaModuleSettingsJVM )
35
+ .jvmSettings(ScalaModulePlugin .scalaModuleOsgiSettings )
9
36
.settings(
10
37
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" ,
11
41
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
+ }),
16
50
17
- scalaModuleMimaPreviousVersion := {
18
- if (System .getenv(" SCALAJS_VERSION" ) == " 1.0.1" ) None
19
- else Some (" 1.2.0" )
20
- },
51
+ Test / scalacOptions += " -Xxml:coalescing" ,
21
52
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)),
31
64
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
+ }),
35
89
36
90
apiMappings ++= scalaInstance.value.libraryJars.filter { file =>
37
91
file.getName.startsWith(" scala-library" ) && file.getName.endsWith(" .jar" )
@@ -47,7 +101,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform)
47
101
file(jarPath)
48
102
-> url(" http://docs.oracle.com/javase/8/docs/api" )
49
103
)
50
- } getOrElse {
104
+ }. getOrElse {
51
105
// If everything fails, jam in Java 11 modules.
52
106
Map (
53
107
file(" /modules/java.base" )
@@ -58,16 +112,50 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform)
58
112
}
59
113
}
60
114
)
115
+ .settings(
116
+ inConfig(Compile )(configSettings) ++ inConfig(Test )(configSettings)
117
+ )
61
118
.jvmSettings(
62
119
OsgiKeys .exportPackage := Seq (s " scala.xml.*;version= ${version.value}" ),
63
120
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
+ }),
68
131
)
69
132
.jsSettings(
70
133
// 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" ),
72
161
)
73
- .jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin ))
0 commit comments