|  | 
| 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 | +  ) | 
| 2 | 25 | 
 | 
| 3 | 26 | lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatform) | 
| 4 |  | -  .withoutSuffixFor(JVMPlatform).in(file(".")) | 
| 5 |  | -  .settings(ScalaModulePlugin.scalaModuleSettings) | 
| 6 |  | -  .jvmSettings(ScalaModulePlugin.scalaModuleSettingsJVM) | 
|  | 27 | +  .in(file(".")) | 
| 7 | 28 |   .settings( | 
|  | 29 | +    ScalaModulePlugin.scalaModuleSettings, | 
|  | 30 | +    commonSettings, | 
| 8 | 31 |     name := "scala-parser-combinators", | 
|  | 32 | +    scalaModuleAutomaticModuleName := Some("scala.util.parsing"), | 
| 9 | 33 | 
 | 
| 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, | 
| 16 | 36 | 
 | 
| 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, | 
| 23 | 42 | 
 | 
| 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, | 
| 26 | 47 | 
 | 
| 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 => | 
| 40 | 85 |         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-") | 
| 43 | 89 |         } | 
| 44 | 90 |       } | 
| 45 |  | -    } | 
|  | 91 | +    }, | 
|  | 92 | +    mimaBinaryIssueFilters ++= { | 
|  | 93 | +      import com.typesafe.tools.mima.core._, ProblemFilters._ | 
|  | 94 | +      Seq( | 
|  | 95 | +        // these are safe to exclude because they're `private[combinator]` | 
|  | 96 | +        exclude[ReversedMissingMethodProblem]("scala.util.parsing.combinator.Parsers.Success"), | 
|  | 97 | +        exclude[ReversedMissingMethodProblem]("scala.util.parsing.combinator.Parsers.selectLastFailure"), | 
|  | 98 | +      ) | 
|  | 99 | +    }, | 
| 46 | 100 |   ) | 
| 47 | 101 |   .jvmSettings( | 
|  | 102 | +    ScalaModulePlugin.scalaModuleOsgiSettings, | 
| 48 | 103 |     OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"), | 
| 49 |  | -    libraryDependencies += "junit" % "junit" % "4.13" % Test, | 
| 50 |  | -    libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test | 
| 51 | 104 |   ) | 
| 52 | 105 |   .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 | +    }), | 
| 53 | 112 |     // Scala.js cannot run forked tests | 
| 54 |  | -    fork in Test := false | 
|  | 113 | +    Test / fork := false | 
| 55 | 114 |   ) | 
| 56 |  | -  .jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)) | 
|  | 115 | +  .jsEnablePlugins(ScalaJSJUnitPlugin) | 
| 57 | 116 |   .nativeSettings( | 
| 58 |  | -    skip in compile := System.getProperty("java.version").startsWith("1.6") || !scalaVersion.value.startsWith("2.11"), | 
| 59 |  | -    test := {}, | 
| 60 |  | -    libraryDependencies := { | 
| 61 |  | -      if (!scalaVersion.value.startsWith("2.11")) | 
| 62 |  | -        libraryDependencies.value.filterNot(_.organization == "org.scala-native") | 
| 63 |  | -      else libraryDependencies.value | 
| 64 |  | -    } | 
|  | 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) | 
| 65 | 123 |   ) | 
|  | 124 | + | 
|  | 125 | +lazy val parserCombinatorsJVM    = parserCombinators.jvm | 
|  | 126 | +lazy val parserCombinatorsJS     = parserCombinators.js | 
|  | 127 | +lazy val parserCombinatorsNative = parserCombinators.native | 
0 commit comments