1- import sbtcrossproject .CrossPlugin .autoImport .crossProject
1+ // in the interest of reducing diffs between the 1.1.x branch and the
2+ // main (2.x branch), there are some Scala 3 references in here that
3+ // aren't affecting anything
4+
5+ ThisBuild / licenses += ((" Apache-2.0" , url(" https://www.apache.org/licenses/LICENSE-2.0" )))
6+ ThisBuild / startYear := Some (2004 )
7+
8+ // I thought we could declare these in `ThisBuild` scope but no :-/
9+ val commonSettings = Seq (
10+ versionScheme := Some (" early-semver" ),
11+ versionPolicyIntention := {
12+ if (scalaVersion.value.startsWith(" 3" ))
13+ Compatibility .None
14+ else
15+ Compatibility .BinaryCompatible
16+ }
17+ )
18+
19+ lazy val root = project.in(file(" ." ))
20+ .aggregate(parserCombinatorsJVM, parserCombinatorsJS, parserCombinatorsNative)
21+ .settings(
22+ commonSettings,
23+ publish / skip := true ,
24+ )
225
326lazy val parserCombinators = crossProject(JVMPlatform , JSPlatform , NativePlatform )
4- .withoutSuffixFor(JVMPlatform ).in(file(" ." ))
5- .settings(ScalaModulePlugin .scalaModuleSettings)
6- .jvmSettings(ScalaModulePlugin .scalaModuleSettingsJVM)
27+ .in(file(" ." ))
728 .settings(
29+ ScalaModulePlugin .scalaModuleSettings,
30+ commonSettings,
831 name := " scala-parser-combinators" ,
32+ scalaModuleAutomaticModuleName := Some (" scala.util.parsing" ),
933
10- scalaModuleMimaPreviousVersion := Some (" 1.1.0" ).filter(_ => System .getenv(" SCALAJS_VERSION" ) != " 1.0.0" ),
11- mimaBinaryIssueFilters ++= {
12- import com .typesafe .tools .mima .core ._
13- import com .typesafe .tools .mima .core .ProblemFilters ._
14- Seq (
15- exclude[IncompatibleSignatureProblem ](" *" ),
34+ crossScalaVersions := Seq (" 2.13.8" , " 2.12.15" , " 2.11.12" ),
35+ scalaVersion := crossScalaVersions.value.head,
1636
17- // the following 3 are due to https://github.com/lightbend/mima/issues/388
18- exclude[DirectMissingMethodProblem ](" scala.util.parsing.json.JSON.numberParser" ),
19- exclude[DirectMissingMethodProblem ](" scala.util.parsing.json.JSON.defaultNumberParser" ),
20- exclude[DirectMissingMethodProblem ](" scala.util.parsing.json.JSON.keywordCache" )
21- )
22- },
37+ libraryDependencies += " junit" % " junit" % " 4.13.2" % Test ,
38+ libraryDependencies += " com.github.sbt" % " junit-interface" % " 0.13.3" % Test ,
39+ // so we can `@nowarn` in test code, but only in test code, so the dependency
40+ // doesn't leak downstream. can be dropped when we drop 2.11 from the crossbuild
41+ libraryDependencies += " org.scala-lang.modules" %% " scala-collection-compat" % " 2.7.0" % Test ,
2342
24- apiMappings += (scalaInstance.value.libraryJar ->
25- url(s " https://www.scala-lang.org/api/ ${scalaVersion.value}/ " )),
43+ apiMappings ++= scalaInstance.value.libraryJars.collect {
44+ case file if file.getName.startsWith(" scala-library" ) && file.getName.endsWith(" .jar" ) =>
45+ file -> url(s " http://www.scala-lang.org/api/ ${scalaVersion.value}/ " )
46+ }.toMap,
2647
27- scalacOptions in (Compile , doc) ++= Seq (
28- " -diagrams" ,
29- " -doc-source-url" ,
30- s " https://github.com/scala/scala-parser-combinators/tree/v ${version.value}€{FILE_PATH}.scala " ,
31- " -sourcepath" ,
32- (baseDirectory in LocalRootProject ).value.absolutePath,
33- " -doc-title" ,
34- " Scala Parser Combinators" ,
35- " -doc-version" ,
36- version.value
37- ),
38- unmanagedSourceDirectories in Compile ++= {
39- (unmanagedSourceDirectories in Compile ).value.map { dir =>
48+ // go nearly warning-free, but only on 2.13, it's too hard across all versions
49+ Compile / scalacOptions ++= (CrossVersion .partialVersion(scalaVersion.value) match {
50+ case Some ((2 , 13 )) => Seq (" -Werror" ,
51+ // ideally we'd do something about this. `^?` is the responsible method
52+ " -Wconf:site=scala.util.parsing.combinator.Parsers.*&cat=lint-multiarg-infix:i" ,
53+ // not sure what resolving this would look like? didn't think about it too hard
54+ " -Wconf:site=scala.util.parsing.combinator.lexical.StdLexical.*&cat=other-match-analysis:i" ,
55+ )
56+ case _ => Seq ()
57+ }),
58+ Compile / doc / scalacOptions ++= (CrossVersion .partialVersion(scalaVersion.value) match {
59+ case Some ((2 , 13 )) => Seq (
60+ // it isn't able to link to [[java.lang.NoSuchMethodError]]
61+ // scala-xml doesn't have this problem, I tried copying their apiMappings stuff
62+ // and that didn't help, I'm mystified why :-/
63+ """ -Wconf:msg=Could not find any member to link for*:i""" ,
64+ )
65+ case _ => Seq ()
66+ }),
67+ Compile / doc / scalacOptions ++= (CrossVersion .partialVersion(scalaVersion.value) match {
68+ case Some ((3 , _)) =>
69+ Seq () // TODO see what flags might be desirable to pass to Scala 3's Scaladoc
70+ case _ =>
71+ Seq (
72+ " -diagrams" ,
73+ " -doc-source-url" ,
74+ s " https://github.com/scala/scala-parser-combinators/tree/v ${version.value}€{FILE_PATH}.scala " ,
75+ " -sourcepath" ,
76+ (LocalRootProject / baseDirectory).value.absolutePath,
77+ " -doc-title" ,
78+ " Scala Parser Combinators" ,
79+ " -doc-version" ,
80+ version.value
81+ )
82+ }),
83+ Compile / unmanagedSourceDirectories ++= {
84+ (Compile / unmanagedSourceDirectories).value.map { dir =>
4085 CrossVersion .partialVersion(scalaVersion.value) match {
41- case Some ((2 , 13 )) => file(dir.getPath ++ " -2.13" )
42- case _ => file(dir.getPath ++ " -2.11-2.12" )
86+ case Some ((2 , 13 )) => file(dir.getPath ++ " -2.13+" )
87+ case Some ((3 , _)) => file(dir.getPath ++ " -2.13+" )
88+ case _ => file(dir.getPath ++ " -2.13-" )
4389 }
4490 }
4591 },
@@ -53,21 +99,29 @@ lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatfor
5399 },
54100 )
55101 .jvmSettings(
102+ ScalaModulePlugin .scalaModuleOsgiSettings,
56103 OsgiKeys .exportPackage := Seq (s " scala.util.parsing.*;version= ${version.value}" ),
57- libraryDependencies += " junit" % " junit" % " 4.13" % Test ,
58- libraryDependencies += " com.novocode" % " junit-interface" % " 0.11" % Test
59104 )
60105 .jsSettings(
106+ // mystified why https://github.com/scala-js/scala-js/issues/635 would be rearing its head,
107+ // but only on sbt 1.4 + 2.13 and only in Test config?! WEIRD
108+ Test / doc / scalacOptions ++= (CrossVersion .partialVersion(scalaVersion.value) match {
109+ case Some ((2 , 13 )) => Seq (" -Wconf:msg=dropping dependency on node with no phase object*:i" )
110+ case _ => Seq ()
111+ }),
61112 // Scala.js cannot run forked tests
62- fork in Test := false
113+ Test / fork := false
63114 )
64- .jsConfigure(_.enablePlugins( ScalaJSJUnitPlugin ) )
115+ .jsEnablePlugins( ScalaJSJUnitPlugin )
65116 .nativeSettings(
66- skip in compile := System .getProperty(" java.version" ).startsWith(" 1.6" ) || ! scalaVersion.value.startsWith(" 2.11" ),
67- test := {},
68- libraryDependencies := {
69- if (! scalaVersion.value.startsWith(" 2.11" ))
70- libraryDependencies.value.filterNot(_.organization == " org.scala-native" )
71- else libraryDependencies.value
72- }
117+ versionPolicyCheck / skip := true ,
118+ versionCheck / skip := true ,
119+ Test / fork := false ,
120+ libraryDependencies :=
121+ libraryDependencies.value.filterNot(_.organization == " junit" ) :+ " org.scala-native" %%% " junit-runtime" % " 0.4.4" ,
122+ addCompilerPlugin(" org.scala-native" % " junit-plugin" % " 0.4.4" cross CrossVersion .full)
73123 )
124+
125+ lazy val parserCombinatorsJVM = parserCombinators.jvm
126+ lazy val parserCombinatorsJS = parserCombinators.js
127+ lazy val parserCombinatorsNative = parserCombinators.native
0 commit comments