From 09d527abf5fa42f66dbceb6d133fbdebdecd0337 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Tue, 20 Jul 2021 16:43:47 -0700 Subject: [PATCH 01/53] bump version in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4418c95b..4502ef91 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ API documentation is available [here](https://javadoc.io/doc/org.scala-lang.modu How to documentation is available in the [wiki](https://github.com/scala/scala-xml/wiki) -The latest stable release of Scala XML is 2.0.0. +The latest stable release of Scala XML is 2.0.1. ## Maintenance status From db2208105116feb7ea795787250777d8d9a8f71f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 27 Jul 2021 17:06:52 +0200 Subject: [PATCH 02/53] Update sbt-version-policy to 1.2.1 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index e916c9c6..9f7ba7a2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -10,4 +10,4 @@ addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") -addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "1.0.1") +addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "1.2.1") From ba30ac6439c0de58a1109c1b99a90ec449f63830 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 3 Aug 2021 23:24:11 +0200 Subject: [PATCH 03/53] Update sbt-scala-module to 2.4.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 9f7ba7a2..e591fd3d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ val scalaJSVersion = val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.4.0") -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.3.1") +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.4.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) From f34cca230c3d4e81c30d18b5f5d582c111487f71 Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Wed, 4 Aug 2021 10:04:35 +0200 Subject: [PATCH 04/53] Adjust build definition and CI process - remove `versionScheme` (already set by sbt-version-policy) - scope `versionPolicyIntention` to projects, instead of to `ThisBuild` - replace `versionPolicyDependencySchemes` with `libraryDependencySchemes` - remove `scalaModuleMimaPreviousVersion` (already set by sbt-version-policy) - remove invocation of `versionPolicyCheck` from CI (already invoked by `test`) - add invocation of `versionCheck` before publishing a release --- build.sbt | 6 ++---- build.sh | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index b560cdaa..6c1e3e93 100644 --- a/build.sbt +++ b/build.sbt @@ -3,10 +3,8 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} ThisBuild / startYear := Some(2002) ThisBuild / licenses += (("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0"))) -ThisBuild / versionScheme := Some("early-semver") -ThisBuild / versionPolicyIntention := Compatibility.BinaryCompatible // because it doesn't declare it itself -ThisBuild / versionPolicyDependencySchemes += "org.scala-js" %% "scalajs-library" % "semver-spec" +ThisBuild / libraryDependencySchemes += "org.scala-js" %% "scalajs-library" % "semver-spec" lazy val configSettings: Seq[Setting[_]] = Seq( unmanagedSourceDirectories ++= { @@ -59,7 +57,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) |""".stripMargin)), // Note: See discussion on non-JVM Mima in https://github.com/scala/scala-xml/pull/517 - scalaModuleMimaPreviousVersion := Some("2.0.0"), + versionPolicyIntention := Compatibility.BinaryAndSourceCompatible, mimaReportSignatureProblems := true, mimaBinaryIssueFilters ++= { import com.typesafe.tools.mima.core._ diff --git a/build.sh b/build.sh index 373cc1ec..ab4af696 100755 --- a/build.sh +++ b/build.sh @@ -37,6 +37,7 @@ verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" tagPat="^v$verPat(#.*)?$" if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then + versionCheckTask="versionCheck" releaseTask="ci-release" if ! isReleaseJob; then echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION" @@ -53,4 +54,4 @@ export CI_SNAPSHOT_RELEASE="${projectPrefix}publish" # for now, until we're confident in the new release scripts, just close the staging repo. export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose" -sbt clean ${projectPrefix}test ${projectPrefix}versionPolicyCheck ${projectPrefix}publishLocal $releaseTask +sbt clean ${projectPrefix}test ${projectPrefix}publishLocal $versionCheckTask $releaseTask From 9f46905eeb4e0e901ac697bdaa9718062f52192a Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Wed, 4 Aug 2021 10:11:47 +0200 Subject: [PATCH 05/53] Adjust CI process - remove invocation of `versionPolicyCheck` from CI (already invoked by `test`) - add invocation of `versionCheck` before publishing a release --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 51dfb564..157191e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ jobs: - run: java -version - sbt_cmd: scala_version: << parameters.scala_version >> - sbt_tasks: xml/update xml/compile xml/Test/compile xml/test xml/doc xml/package xml/osgiBundle xml/versionPolicyCheck + sbt_tasks: xml/update xml/compile xml/Test/compile xml/test xml/doc xml/package xml/osgiBundle scalajs_job: executor: scala_jdk8_executor parameters: From 5c746cb6a7dd986dbd08c06aa05eb35351f2f650 Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Wed, 4 Aug 2021 10:13:51 +0200 Subject: [PATCH 06/53] Remove sbt-version-policy --- project/plugins.sbt | 1 - 1 file changed, 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index e591fd3d..1df3b784 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -10,4 +10,3 @@ addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") -addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "1.2.1") From 06e8a208e302b8c491c92a5a8158666ce0066ba3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 3 Aug 2021 23:24:08 +0200 Subject: [PATCH 07/53] Update sbt-scalajs, scalajs-compiler, ... to 1.7.0 --- .circleci/config.yml | 4 ++-- .travis.yml | 2 +- project/plugins.sbt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 51dfb564..6144e842 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -141,11 +141,11 @@ workflows: - scalajs_job: name: sjs1.0_2.12 scala_version: 2.12.14 - scalajs_version: 1.6.0 + scalajs_version: 1.7.0 - scalajs_job: name: sjs1.0_2.13 scala_version: 2.13.6 - scalajs_version: 1.6.0 + scalajs_version: 1.7.0 - scalanative_job: name: native0.4_2.12 scala_version: 2.12.14 diff --git a/.travis.yml b/.travis.yml index 9385cc93..ac00ec9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ scala: env: - SCALAJS_VERSION= ADOPTOPENJDK=8 - - SCALAJS_VERSION=1.6.0 ADOPTOPENJDK=8 + - SCALAJS_VERSION=1.7.0 ADOPTOPENJDK=8 - SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8 - SCALAJS_VERSION= ADOPTOPENJDK=11 - SCALAJS_VERSION= ADOPTOPENJDK=17 diff --git a/project/plugins.sbt b/project/plugins.sbt index 9f7ba7a2..cf1d6ece 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.6.0") + Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.7.0") val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.4.0") From cac2aa2c8ef840d9f1a23a02b3f65a447e606581 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Sun, 29 Aug 2021 20:09:37 -0400 Subject: [PATCH 08/53] Add Scala.js on 3.0.1 to Circle --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cc60eb1..fe952eb9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -146,6 +146,10 @@ workflows: name: sjs1.0_2.13 scala_version: 2.13.6 scalajs_version: 1.7.0 + - scalajs_job: + name: sjs1.0_3 + scala_version: 3.0.1 + scalajs_version: 1.7.0 - scalanative_job: name: native0.4_2.12 scala_version: 2.12.14 From 0f2e26bc9afb493776957483245f1b79c80472e8 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Tue, 31 Aug 2021 16:59:09 -0400 Subject: [PATCH 09/53] Relax versionPolicyIntention to BinaryCompatible --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6c1e3e93..7b86182d 100644 --- a/build.sbt +++ b/build.sbt @@ -56,8 +56,9 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) |additional information regarding copyright ownership. |""".stripMargin)), + // Note: Change back to BinaryAndSourceCompatible after 2.1.0 release + versionPolicyIntention := Compatibility.BinaryCompatible, // Note: See discussion on non-JVM Mima in https://github.com/scala/scala-xml/pull/517 - versionPolicyIntention := Compatibility.BinaryAndSourceCompatible, mimaReportSignatureProblems := true, mimaBinaryIssueFilters ++= { import com.typesafe.tools.mima.core._ From 2b96e29b8643c35985e8588f25959ad76156864d Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Tue, 31 Aug 2021 17:11:57 -0400 Subject: [PATCH 10/53] Fix Circle 'clang-7' has no installation candidate --- .circleci/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cc60eb1..f5572250 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,9 +92,7 @@ jobs: name: Install dependencies command: | sudo apt-get update - sudo apt-get install -y clang-7 - sudo ln -s /usr/lib/llvm-7/bin/clang /usr/local/bin/clang - sudo ln -s /usr/lib/llvm-7/bin/clang++ /usr/local/bin/clang++ + sudo apt-get install -y clang - sbt_cmd: scala_version: << parameters.scala_version >> sbt_tasks: xmlNative/update xmlNative/compile xmlNative/test:compile xmlNative/test xmlNative/doc xmlNative/package From f92ae49181989764d591f5b2b6d843ce9d12bfa8 Mon Sep 17 00:00:00 2001 From: Leonid Dubinsky Date: Wed, 18 Aug 2021 13:04:36 -0400 Subject: [PATCH 11/53] Do not ignore XML comments when parsing: fixes #508 - set `org.xml.sax.ext.LexicalHandler` on the `SAXParser` that `XMLLoader` uses; - override `LexicalHandler.comment()` in `FactoryAdapter` so that comments are added to the element content; - add unit tests; - add excludes for the binary compatibility checks. --- build.sbt | 9 +++++++ jvm/src/test/scala/scala/xml/XMLTest.scala | 17 ++++++++++-- .../scala/scala/xml/factory/NodeFactory.scala | 4 +-- .../scala/scala/xml/factory/XMLLoader.scala | 13 ++++++--- .../scala/xml/parsing/FactoryAdapter.scala | 27 +++++++++++++------ .../xml/parsing/NoBindingFactoryAdapter.scala | 13 +++++---- 6 files changed, 63 insertions(+), 20 deletions(-) diff --git a/build.sbt b/build.sbt index 7b86182d..eb8ab9b6 100644 --- a/build.sbt +++ b/build.sbt @@ -68,6 +68,15 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) // 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"), + + // caused by the switch from DefaultHandler to DefaultHandler2: + exclude[MissingTypesProblem]("scala.xml.parsing.FactoryAdapter"), + exclude[MissingTypesProblem]("scala.xml.parsing.NoBindingFactoryAdapter"), + + exclude[DirectMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.comment"), + exclude[ReversedMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createComment"), + exclude[DirectMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createComment"), + exclude[DirectMissingMethodProblem]("scala.xml.parsing.NoBindingFactoryAdapter.createComment") ) }, diff --git a/jvm/src/test/scala/scala/xml/XMLTest.scala b/jvm/src/test/scala/scala/xml/XMLTest.scala index e4321aa6..70b59a92 100644 --- a/jvm/src/test/scala/scala/xml/XMLTest.scala +++ b/jvm/src/test/scala/scala/xml/XMLTest.scala @@ -6,7 +6,6 @@ import org.junit.{Test => UnitTest} import org.junit.Assert.assertTrue import org.junit.Assert.assertFalse import org.junit.Assert.assertEquals -import scala.xml.parsing.ConstructingParser import java.io.StringWriter import java.io.ByteArrayOutputStream import java.io.StringReader @@ -581,6 +580,21 @@ class XMLTestJVM { XML.loadString(broken) } + @UnitTest + def issue508: Unit = { + def check(xml: String): Unit = assertEquals(xml, XML.loadString(xml).toString) + + check(" suffix") + check("prefix suffix") + check("prefix suffix") + + // TODO since XMLLoader retrieves FactoryAdapter.rootNode, + // capturing comments before and after the root element is not currently possible + // (by the way, the same applies to processing instructions). + //check("text") + //check("text") + } + @UnitTest def nodeSeqNs: Unit = { val x = { @@ -746,5 +760,4 @@ class XMLTestJVM { assertEquals("", x.xEntityValue()) } - } diff --git a/shared/src/main/scala/scala/xml/factory/NodeFactory.scala b/shared/src/main/scala/scala/xml/factory/NodeFactory.scala index ad70d888..7ae0fd7e 100644 --- a/shared/src/main/scala/scala/xml/factory/NodeFactory.scala +++ b/shared/src/main/scala/scala/xml/factory/NodeFactory.scala @@ -34,7 +34,7 @@ trait NodeFactory[A <: Node] { def eqElements(ch1: Seq[Node], ch2: Seq[Node]): Boolean = ch1.view.zipAll(ch2.view, null, null) forall { case (x, y) => x eq y } - def nodeEquals(n: Node, pre: String, name: String, attrSeq: MetaData, scope: NamespaceBinding, children: Seq[Node]) = + def nodeEquals(n: Node, pre: String, name: String, attrSeq: MetaData, scope: NamespaceBinding, children: Seq[Node]): Boolean = n.prefix == pre && n.label == name && n.attributes == attrSeq && @@ -55,7 +55,7 @@ trait NodeFactory[A <: Node] { } } - def makeText(s: String) = Text(s) + def makeText(s: String): Text = Text(s) def makeComment(s: String): Seq[Comment] = if (ignoreComments) Nil else List(Comment(s)) def makeProcInstr(t: String, s: String): Seq[ProcInstr] = diff --git a/shared/src/main/scala/scala/xml/factory/XMLLoader.scala b/shared/src/main/scala/scala/xml/factory/XMLLoader.scala index 00f43074..7562c0c1 100644 --- a/shared/src/main/scala/scala/xml/factory/XMLLoader.scala +++ b/shared/src/main/scala/scala/xml/factory/XMLLoader.scala @@ -14,9 +14,10 @@ package scala package xml package factory +import org.xml.sax.SAXNotRecognizedException import javax.xml.parsers.SAXParserFactory -import parsing.{ FactoryAdapter, NoBindingFactoryAdapter } -import java.io.{ InputStream, Reader, File, FileDescriptor } +import parsing.{FactoryAdapter, NoBindingFactoryAdapter} +import java.io.{File, FileDescriptor, InputStream, Reader} import java.net.URL /** @@ -28,7 +29,7 @@ trait XMLLoader[T <: Node] { def adapter: FactoryAdapter = new NoBindingFactoryAdapter() private lazy val parserInstance = new ThreadLocal[SAXParser] { - override def initialValue = { + override def initialValue: SAXParser = { val parser = SAXParserFactory.newInstance() parser.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true) parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) @@ -52,6 +53,12 @@ trait XMLLoader[T <: Node] { def loadXML(source: InputSource, parser: SAXParser): T = { val newAdapter = adapter + try { + parser.setProperty("http://xml.org/sax/properties/lexical-handler", newAdapter) + } catch { + case _: SAXNotRecognizedException => + } + newAdapter.scopeStack = TopScope :: newAdapter.scopeStack parser.parse(source, newAdapter) newAdapter.scopeStack = newAdapter.scopeStack.tail diff --git a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala index accc9a68..c6c8849d 100644 --- a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala +++ b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala @@ -16,10 +16,10 @@ package parsing import scala.collection.Seq import org.xml.sax.Attributes -import org.xml.sax.helpers.DefaultHandler +import org.xml.sax.ext.DefaultHandler2 // can be mixed into FactoryAdapter if desired -trait ConsoleErrorHandler extends DefaultHandler { +trait ConsoleErrorHandler extends DefaultHandler2 { // ignore warning, crimson warns even for entity resolution! override def warning(ex: SAXParseException): Unit = {} override def error(ex: SAXParseException): Unit = printError("Error", ex) @@ -39,8 +39,8 @@ trait ConsoleErrorHandler extends DefaultHandler { * namespace bindings, without relying on namespace handling of the * underlying SAX parser. */ -abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node] { - var rootElem: Node = null +abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Node] { + var rootElem: Node = _ val buffer = new StringBuilder() /** List of attributes @@ -72,7 +72,7 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node */ var scopeStack = List.empty[NamespaceBinding] - var curTag: String = null + var curTag: String = _ var capture: Boolean = false // abstract methods @@ -105,6 +105,11 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node */ def createProcInstr(target: String, data: String): Seq[ProcInstr] + /** + * creates a new comment node. + */ + def createComment(characters: String): Seq[Comment] + // // ContentHandler methods // @@ -118,7 +123,7 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node * @param length */ override def characters(ch: Array[Char], offset: Int, length: Int): Unit = { - if (!capture) return + if (!capture) () // compliant: report every character else if (!normalizeWhitespace) buffer.appendAll(ch, offset, length) // normalizing whitespace is not compliant, but useful @@ -170,7 +175,7 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node if (pre == "xmlns" || (pre == null && qname == "xmlns")) { val arg = if (pre == null) null else key - scpe = new NamespaceBinding(arg, nullIfEmpty(value), scpe) + scpe = NamespaceBinding(arg, nullIfEmpty(value), scpe) } else m = Attribute(Option(pre), key, Text(value), m) } @@ -183,7 +188,7 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node * captures text, possibly normalizing whitespace */ def captureText(): Unit = { - if (capture && buffer.length > 0) + if (capture && buffer.nonEmpty) hStack = createText(buffer.toString) :: hStack buffer.clear() @@ -226,4 +231,10 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node captureText() hStack = hStack.reverse_:::(createProcInstr(target, data).toList) } + + override def comment(ch: Array[Char], start: Int, length: Int): Unit = { + captureText() + val commentText: String = String.valueOf(ch.slice(start, start + length)) + hStack = hStack.reverse_:::(createComment(commentText).toList) + } } diff --git a/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala b/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala index 819d8ca3..6f1384fc 100644 --- a/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala +++ b/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala @@ -23,20 +23,23 @@ import factory.NodeFactory */ class NoBindingFactoryAdapter extends FactoryAdapter with NodeFactory[Elem] { /** True. Every XML node may contain text that the application needs */ - def nodeContainsText(label: String) = true + override def nodeContainsText(label: String) = true /** From NodeFactory. Constructs an instance of scala.xml.Elem -- TODO: deprecate as in Elem */ - protected def create(pre: String, label: String, attrs: MetaData, scope: NamespaceBinding, children: Seq[Node]): Elem = + override protected def create(pre: String, label: String, attrs: MetaData, scope: NamespaceBinding, children: Seq[Node]): Elem = Elem(pre, label, attrs, scope, children.isEmpty, children: _*) /** From FactoryAdapter. Creates a node. never creates the same node twice, using hash-consing. TODO: deprecate as in Elem, or forward to create?? */ - def createNode(pre: String, label: String, attrs: MetaData, scope: NamespaceBinding, children: List[Node]): Elem = + override def createNode(pre: String, label: String, attrs: MetaData, scope: NamespaceBinding, children: List[Node]): Elem = Elem(pre, label, attrs, scope, children.isEmpty, children: _*) /** Creates a text node. */ - def createText(text: String) = Text(text) + override def createText(text: String): Text = makeText(text) /** Creates a processing instruction. */ - def createProcInstr(target: String, data: String) = makeProcInstr(target, data) + override def createProcInstr(target: String, data: String): Seq[ProcInstr] = makeProcInstr(target, data) + + /** Creates a comment. */ + override def createComment(characters: String): Seq[Comment] = makeComment(characters) } From 3bc9bd682fd86032e16b8df376e22f6e9c80f8dc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 1 Sep 2021 13:29:22 +0200 Subject: [PATCH 12/53] Update scala3-library, ... to 3.0.2 --- .circleci/config.yml | 8 ++++---- .travis.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f3168d6c..744a5885 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -111,7 +111,7 @@ workflows: - scala_job: name: 3.0.1 java_version: jdk8 - scala_version: 3.0.1 + scala_version: 3.0.2 - scala_job: name: jdk11_2.12 java_version: jdk11 @@ -123,7 +123,7 @@ workflows: - scala_job: name: jdk11_3.0 java_version: jdk11 - scala_version: 3.0.1 + scala_version: 3.0.2 - scala_job: name: jdk17_2.12 java_version: jdk17 @@ -135,7 +135,7 @@ workflows: - scala_job: name: jdk17_3.0 java_version: jdk17 - scala_version: 3.0.1 + scala_version: 3.0.2 - scalajs_job: name: sjs1.0_2.12 scala_version: 2.12.14 @@ -146,7 +146,7 @@ workflows: scalajs_version: 1.7.0 - scalajs_job: name: sjs1.0_3 - scala_version: 3.0.1 + scala_version: 3.0.2 scalajs_version: 1.7.0 - scalanative_job: name: native0.4_2.12 diff --git a/.travis.yml b/.travis.yml index ac00ec9b..f781ceb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: jobs: exclude: - - scala: 3.0.1 + - scala: 3.0.2 env: SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8 install: From 52f5e9ed6531fc1d29fdcaff87c5b79ade39a81f Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Wed, 1 Sep 2021 07:49:11 -0400 Subject: [PATCH 13/53] Fix job name to 3.0.2 in Circle --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 744a5885..4901a30a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -109,7 +109,7 @@ workflows: java_version: jdk8 scala_version: 2.13.6 - scala_job: - name: 3.0.1 + name: 3.0.2 java_version: jdk8 scala_version: 3.0.2 - scala_job: From 5f3042410eaab8aaa2de4a2405a91e313b973d7e Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Wed, 1 Sep 2021 07:49:46 -0400 Subject: [PATCH 14/53] Update 3.0.2 in Travis matrix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f781ceb8..9f47674b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ import: scala/scala-dev:travis/default.yml language: scala scala: - - 3.0.1 + - 3.0.2 - 2.12.14 - 2.13.6 From 5e8aba5d0820c8aa854b98b65ad966feed57c894 Mon Sep 17 00:00:00 2001 From: Leonid Dubinsky Date: Wed, 1 Sep 2021 14:33:56 -0400 Subject: [PATCH 15/53] Do not ignore XML CDATA sections when parsing: - handle startCDATA/endCDATA lexical events; - keep track of the `inCDATA` state; - capture text into appropriate Node subtype depending on that state; - add createPCData()/makePCData() helpers; - add unit tests. --- build.sbt | 12 +++--- jvm/src/test/scala/scala/xml/XMLTest.scala | 31 ++++++++++++--- .../scala/scala/xml/factory/NodeFactory.scala | 2 + .../scala/xml/parsing/FactoryAdapter.scala | 39 ++++++++++++++++--- .../xml/parsing/NoBindingFactoryAdapter.scala | 3 ++ .../test/scala/scala/xml/CommentTest.scala | 1 - 6 files changed, 70 insertions(+), 18 deletions(-) diff --git a/build.sbt b/build.sbt index eb8ab9b6..9bc3a309 100644 --- a/build.sbt +++ b/build.sbt @@ -69,14 +69,12 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) // to previous-version artifacts that were built on 8. see scala/scala-xml#501 exclude[DirectMissingMethodProblem]("scala.xml.include.sax.XIncluder.declaration"), - // caused by the switch from DefaultHandler to DefaultHandler2: - exclude[MissingTypesProblem]("scala.xml.parsing.FactoryAdapter"), - exclude[MissingTypesProblem]("scala.xml.parsing.NoBindingFactoryAdapter"), + // necessitated by the switch from DefaultHandler to DefaultHandler2 in FactoryAdapter: + exclude[MissingTypesProblem]("scala.xml.parsing.FactoryAdapter"), // see #549 - exclude[DirectMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.comment"), - exclude[ReversedMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createComment"), - exclude[DirectMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createComment"), - exclude[DirectMissingMethodProblem]("scala.xml.parsing.NoBindingFactoryAdapter.createComment") + // 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 ) }, diff --git a/jvm/src/test/scala/scala/xml/XMLTest.scala b/jvm/src/test/scala/scala/xml/XMLTest.scala index 70b59a92..23dae29a 100644 --- a/jvm/src/test/scala/scala/xml/XMLTest.scala +++ b/jvm/src/test/scala/scala/xml/XMLTest.scala @@ -580,13 +580,23 @@ class XMLTestJVM { XML.loadString(broken) } + def roundtrip(xml: String): Unit = assertEquals(xml, XML.loadString(xml).toString) + @UnitTest - def issue508: Unit = { - def check(xml: String): Unit = assertEquals(xml, XML.loadString(xml).toString) + def issue508commentParsing: Unit = { + // confirm that comments are processed correctly now + roundtrip(" suffix") + roundtrip("prefix suffix") + roundtrip("prefix suffix") + roundtrip("prefix suffix") + roundtrip("""prefix suffix""".stripMargin) - check(" suffix") - check("prefix suffix") - check("prefix suffix") + // confirm that processing instructions were always processed correctly + roundtrip(" suffix") + roundtrip("prefix suffix") + roundtrip("prefix suffix") // TODO since XMLLoader retrieves FactoryAdapter.rootNode, // capturing comments before and after the root element is not currently possible @@ -595,6 +605,17 @@ class XMLTestJVM { //check("text") } + @UnitTest + def cdataParsing: Unit = { + roundtrip(" suffix") + roundtrip("prefix suffix") + roundtrip("prefix suffix") + roundtrip("""prefix suffix""".stripMargin) + } + @UnitTest def nodeSeqNs: Unit = { val x = { diff --git a/shared/src/main/scala/scala/xml/factory/NodeFactory.scala b/shared/src/main/scala/scala/xml/factory/NodeFactory.scala index 7ae0fd7e..c6b1704b 100644 --- a/shared/src/main/scala/scala/xml/factory/NodeFactory.scala +++ b/shared/src/main/scala/scala/xml/factory/NodeFactory.scala @@ -56,6 +56,8 @@ trait NodeFactory[A <: Node] { } def makeText(s: String): Text = Text(s) + def makePCData(s: String): PCData = + PCData(s) def makeComment(s: String): Seq[Comment] = if (ignoreComments) Nil else List(Comment(s)) def makeProcInstr(t: String, s: String): Seq[ProcInstr] = diff --git a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala index c6c8849d..1ac7e9f0 100644 --- a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala +++ b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala @@ -43,6 +43,8 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod var rootElem: Node = _ val buffer = new StringBuilder() + private var inCDATA: Boolean = false + /** List of attributes * * Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]]. @@ -100,6 +102,13 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod */ def createText(text: String): Text // abstract + /** + * creates a PCData node. + * @param text + * @return a new PCData node. + */ + def createPCData(text: String): PCData // abstract + /** * creates a new processing instruction node. */ @@ -117,7 +126,7 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod val normalizeWhitespace = false /** - * Characters. + * Capture characters, possibly normalizing whitespace. * @param ch * @param offset * @param length @@ -139,7 +148,20 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod } } - private def splitName(s: String) = { + /** + * Start of a CDATA section. + */ + override def startCDATA(): Unit = { + captureText() + inCDATA = true + } + + /** + * End of a CDATA section. + */ + override def endCDATA(): Unit = captureText() + + private def splitName(s: String): (String, String) = { val idx = s indexOf ':' if (idx < 0) (null, s) else (s take idx, s drop (idx + 1)) @@ -185,13 +207,17 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod } /** - * captures text, possibly normalizing whitespace + * Captures text or cdata. */ def captureText(): Unit = { - if (capture && buffer.nonEmpty) - hStack = createText(buffer.toString) :: hStack + if (capture && buffer.nonEmpty) { + val text: String = buffer.toString + val newNode: Node = if (inCDATA) createPCData(text) else createText(text) + hStack = newNode :: hStack + } buffer.clear() + inCDATA = false } /** @@ -232,6 +258,9 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod hStack = hStack.reverse_:::(createProcInstr(target, data).toList) } + /** + * Comment. + */ override def comment(ch: Array[Char], start: Int, length: Int): Unit = { captureText() val commentText: String = String.valueOf(ch.slice(start, start + length)) diff --git a/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala b/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala index 6f1384fc..9e5e0a5c 100644 --- a/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala +++ b/shared/src/main/scala/scala/xml/parsing/NoBindingFactoryAdapter.scala @@ -42,4 +42,7 @@ class NoBindingFactoryAdapter extends FactoryAdapter with NodeFactory[Elem] { /** Creates a comment. */ override def createComment(characters: String): Seq[Comment] = makeComment(characters) + + /** Creates a cdata. */ + override def createPCData(characters: String): PCData = makePCData(characters) } diff --git a/shared/src/test/scala/scala/xml/CommentTest.scala b/shared/src/test/scala/scala/xml/CommentTest.scala index 3e7d1147..0e077a96 100644 --- a/shared/src/test/scala/scala/xml/CommentTest.scala +++ b/shared/src/test/scala/scala/xml/CommentTest.scala @@ -1,7 +1,6 @@ package scala.xml import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue import org.junit.Test final class CommentTest { From fe2b547765258b9e9fb9f696010ad96c012aa4de Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Wed, 1 Sep 2021 17:16:19 -0400 Subject: [PATCH 16/53] Disable Mima signature check on Scala 3.0.2 --- build.sbt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7b86182d..65e5677e 100644 --- a/build.sbt +++ b/build.sbt @@ -59,7 +59,6 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) // Note: Change back to BinaryAndSourceCompatible after 2.1.0 release versionPolicyIntention := Compatibility.BinaryCompatible, // Note: See discussion on non-JVM Mima in https://github.com/scala/scala-xml/pull/517 - mimaReportSignatureProblems := true, mimaBinaryIssueFilters ++= { import com.typesafe.tools.mima.core._ import com.typesafe.tools.mima.core.ProblemFilters._ @@ -70,6 +69,11 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) exclude[DirectMissingMethodProblem]("scala.xml.include.sax.XIncluder.declaration"), ) }, + // 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") From 800817392b3cdad3acbb32e3d8b732fc30dd8ea6 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Thu, 9 Sep 2021 09:59:34 -0400 Subject: [PATCH 17/53] Add 2.0.1 entry in CHANGELOG --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47db07d2..4cb52911 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Scala XML Changes +## 2.0.1 (2021-07-21) + +Binary compatible with Scala XML 2.0.0. + +Published for Scala 2.12 and 2.13, Scala 3, Scala.js 1.6, and Scala +Native 0.4. + +### Added + +- No new functionality. + +### Fixed + +- Fixed runtime error for `MarkupParser` on Scala 3 by changing the + access modifier of internal class, `WithLookAhead` (#542) + ## 2.0.0 (2021-05-13) Not binary compatible with Scala XML 1.3.0. From a6e211bf7f0a72c861c498d8f008e522fb0cd510 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 15 Sep 2021 02:20:27 +0200 Subject: [PATCH 18/53] Update scala-compiler, scala-library to 2.12.15 --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4901a30a..3f2bdfc0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,7 +103,7 @@ workflows: - scala_job: name: 2.12.14 java_version: jdk8 - scala_version: 2.12.14 + scala_version: 2.12.15 - scala_job: name: 2.13.6 java_version: jdk8 @@ -115,7 +115,7 @@ workflows: - scala_job: name: jdk11_2.12 java_version: jdk11 - scala_version: 2.12.14 + scala_version: 2.12.15 - scala_job: name: jdk11_2.13 java_version: jdk11 @@ -127,7 +127,7 @@ workflows: - scala_job: name: jdk17_2.12 java_version: jdk17 - scala_version: 2.12.14 + scala_version: 2.12.15 - scala_job: name: jdk17_2.13 java_version: jdk17 @@ -138,7 +138,7 @@ workflows: scala_version: 3.0.2 - scalajs_job: name: sjs1.0_2.12 - scala_version: 2.12.14 + scala_version: 2.12.15 scalajs_version: 1.7.0 - scalajs_job: name: sjs1.0_2.13 @@ -150,7 +150,7 @@ workflows: scalajs_version: 1.7.0 - scalanative_job: name: native0.4_2.12 - scala_version: 2.12.14 + scala_version: 2.12.15 scalanative_version: 0.4.0 - scalanative_job: name: native0.4_2.13 From bb2ec1d4ae8d1ac1a1764e862710428e2b4a6e62 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Tue, 14 Sep 2021 22:50:20 -0400 Subject: [PATCH 19/53] Update Travis to Scala 2.12.15 --- .circleci/config.yml | 10 +++++----- .travis.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f2bdfc0..c924784c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ commands: parameters: scala_version: type: string - default: 2.12.14 + default: 2.12.15 sbt_tasks: type: string default: update compile test:compile test doc package osgiBundle @@ -41,7 +41,7 @@ jobs: parameters: scala_version: description: "Scala version" - default: 2.12.14 + default: 2.12.15 type: string java_version: description: "Java version" @@ -58,7 +58,7 @@ jobs: parameters: scala_version: description: "Scala version" - default: 2.12.14 + default: 2.12.15 type: string scalajs_version: description: "ScalaJS version" @@ -78,7 +78,7 @@ jobs: parameters: scala_version: description: "Scala version" - default: 2.12.14 + default: 2.12.15 type: string scalanative_version: description: "Scala Native version" @@ -101,7 +101,7 @@ workflows: build: jobs: - scala_job: - name: 2.12.14 + name: 2.12.15 java_version: jdk8 scala_version: 2.12.15 - scala_job: diff --git a/.travis.yml b/.travis.yml index 9f47674b..670b12f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ language: scala scala: - 3.0.2 - - 2.12.14 + - 2.12.15 - 2.13.6 env: From b289ffcc9538da746c5a83baa11fb9a1c3b0ebc9 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Wed, 29 Sep 2021 15:35:28 -0600 Subject: [PATCH 20/53] in with GitHub Actions, out with Travis-CI --- .github/workflows/ci.yml | 25 ++++++++ .github/workflows/release.yml | 21 +++++++ .travis.yml | 27 --------- README.md | 1 - build.sbt | 5 ++ build.sh | 57 ------------------- project/plugins.sbt | 12 +--- .../scala/xml/ScalaVersionSpecific.scala | 12 ++++ 8 files changed, 66 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml delete mode 100755 build.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3aa63aa3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: test +on: + push: + branches: + - main + pull_request: +jobs: + test: + strategy: + fail-fast: false + matrix: + java: [8, 11, 17] + scala: [2.12.15, 2.13.6, 3.0.2] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: ${{matrix.java}} + - name: Test + run: sbt ++${{matrix.scala}} test headerCheck versionPolicyCheck package diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..dc337111 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Release +on: + push: + tags: ["*"] +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 8 + - run: sbt versionCheck ci-release + env: + PGP_PASSPHRASE: ${{secrets.PGP_PASSPHRASE}} + PGP_SECRET: ${{secrets.PGP_SECRET}} + SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}} + SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 670b12f9..00000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: ~> 1.0 # needed for imports - -import: scala/scala-dev:travis/default.yml - -language: scala - -scala: - - 3.0.2 - - 2.12.15 - - 2.13.6 - -env: - - SCALAJS_VERSION= ADOPTOPENJDK=8 - - SCALAJS_VERSION=1.7.0 ADOPTOPENJDK=8 - - SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8 - - SCALAJS_VERSION= ADOPTOPENJDK=11 - - SCALAJS_VERSION= ADOPTOPENJDK=17 - -jobs: - exclude: - - scala: 3.0.2 - env: SCALANATIVE_VERSION=0.4.0 ADOPTOPENJDK=8 - -install: - - git fetch --tags # get all tags for sbt-dynver - -script: ./build.sh diff --git a/README.md b/README.md index 4502ef91..535484a2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ scala-xml -[![Travis](https://img.shields.io/travis/scala/scala-xml.svg)](https://travis-ci.org/scala/scala-xml) [![latest release for 2.12](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_2.12.svg?label=scala+2.12)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.12) [![latest release for 2.13](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_2.13.svg?label=scala+2.13)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.13) [![latest release for 3.0](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_3.svg?label=scala+3)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_3) diff --git a/build.sbt b/build.sbt index 674a474c..fc3906c0 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,7 @@ 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"))) @@ -33,6 +35,8 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings( name := "scala-xml", scalaModuleAutomaticModuleName := Some("scala.xml"), + crossScalaVersions := Seq("2.13.6", "2.12.15", "3.0.2"), + scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((3, _)) => Seq("-language:Scala2") @@ -129,6 +133,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .jsEnablePlugins(ScalaJSJUnitPlugin) .nativeSettings( + crossScalaVersions := Seq("2.13.6", "2.12.15"), // Scala Native cannot run forked tests Test / fork := false, libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test, diff --git a/build.sh b/build.sh deleted file mode 100755 index ab4af696..00000000 --- a/build.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -set -e - -# Builds of tagged revisions are published to sonatype staging. - -# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice. -# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds. - -# sbt-dynver sets the version number from the tag -# sbt-travisci sets the Scala version from the travis job matrix - -# To back-publish an existing release for a new Scala / Scala.js / Scala Native version: -# - check out the tag for the version that needs to be published -# - change `.travis.yml` to adjust the version numbers and trim down the build matrix as necessary -# - commit the changes and tag this new revision with an arbitrary suffix after a hash, e.g., -# `v1.2.3#dotty-0.27` (the suffix is ignored, the version will be `1.2.3`) - -# We release on JDK 8 (for Scala 2.x and Dotty 0.x) -isReleaseJob() { - if [[ "$ADOPTOPENJDK" == "8" ]]; then - true - else - false - fi -} - -if [[ "$SCALAJS_VERSION" == "" ]] && [[ "$SCALANATIVE_VERSION" == "" ]]; then - projectPrefix="xml/" -elif [[ "$SCALAJS_VERSION" == "" ]]; then - projectPrefix="xmlNative/" -else - projectPrefix="xmlJS/" -fi - -verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" -tagPat="^v$verPat(#.*)?$" - -if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then - versionCheckTask="versionCheck" - releaseTask="ci-release" - if ! isReleaseJob; then - echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION" - exit 0 - fi -fi - -# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions -export CI_RELEASE="${projectPrefix}publishSigned" -export CI_SNAPSHOT_RELEASE="${projectPrefix}publish" - -# default is sonatypeBundleRelease, which closes and releases the staging repo -# see https://github.com/xerial/sbt-sonatype#commands -# for now, until we're confident in the new release scripts, just close the staging repo. -export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose" - -sbt clean ${projectPrefix}test ${projectPrefix}publishLocal $versionCheckTask $releaseTask diff --git a/project/plugins.sbt b/project/plugins.sbt index e82b291f..32c1365e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,12 +1,6 @@ -val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.7.0") - -val scalaNativeVersion = - Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.4.0") - -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.4.0") +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) -addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") diff --git a/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala b/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala index 417a3bcc..af7daf76 100644 --- a/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala +++ b/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala @@ -1,3 +1,15 @@ +/* + * 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. + */ + package scala.xml import scala.collection.SeqLike From 156f2eae94e290192bc75b412a05952bea9d0895 Mon Sep 17 00:00:00 2001 From: Leonid Dubinsky Date: Fri, 10 Sep 2021 14:50:32 -0400 Subject: [PATCH 21/53] XML allows for comments and processing instructions to be present before the start and after the end of the root element. Currently, `FactoryAdapter` does not capture those nodes, and `XMLLoader.loadXML` does not provide access to anything other than the root element anyway. This pull request addresses the issue. Note: at least with the JDK's Xerces, whitespace in the prolog and epilogue gets lost in parsing: the parser does not fire any white-space related events. --- jvm/src/test/scala/scala/xml/XMLTest.scala | 31 +++++++++++----- .../scala/scala/xml/factory/XMLLoader.scala | 35 +++++++++++++++---- .../scala/xml/parsing/FactoryAdapter.scala | 31 +++++++++++----- .../scala/xml/parsing/MarkupParser.scala | 2 ++ 4 files changed, 75 insertions(+), 24 deletions(-) diff --git a/jvm/src/test/scala/scala/xml/XMLTest.scala b/jvm/src/test/scala/scala/xml/XMLTest.scala index 23dae29a..e7f3624f 100644 --- a/jvm/src/test/scala/scala/xml/XMLTest.scala +++ b/jvm/src/test/scala/scala/xml/XMLTest.scala @@ -586,7 +586,7 @@ class XMLTestJVM { def issue508commentParsing: Unit = { // confirm that comments are processed correctly now roundtrip(" suffix") - roundtrip("prefix suffix") + roundtrip("prefix suffix") roundtrip("prefix suffix") roundtrip("prefix suffix") roundtrip("""prefix text") - //check("text") + roundtrip("prefix suffix") } @UnitTest @@ -613,7 +607,26 @@ class XMLTestJVM { roundtrip("""prefix suffix""".stripMargin) + | section]]> suffix""".stripMargin) + } + + def roundtripNodes(xml: String): Unit = assertEquals(xml, XML.loadStringNodes(xml).map(_.toString).mkString("")) + + @UnitTest + def xmlLoaderLoadNodes: Unit = { + roundtripNodes("text") + roundtripNodes("text") + roundtripNodes("""text""".stripMargin) + + roundtripNodes("text") + roundtripNodes("text") + + // Note: at least with the JDK's Xerces, whitespace in the prolog and epilogue gets lost in parsing: + // the parser does not fire any white-space related events, so: + // does not work: roundtripNodes(" ") + // does not work: roundtripNodes(" ") } @UnitTest diff --git a/shared/src/main/scala/scala/xml/factory/XMLLoader.scala b/shared/src/main/scala/scala/xml/factory/XMLLoader.scala index 7562c0c1..620e1b6e 100644 --- a/shared/src/main/scala/scala/xml/factory/XMLLoader.scala +++ b/shared/src/main/scala/scala/xml/factory/XMLLoader.scala @@ -51,19 +51,29 @@ trait XMLLoader[T <: Node] { * The methods available in scala.xml.XML use the XML parser in the JDK. */ def loadXML(source: InputSource, parser: SAXParser): T = { - val newAdapter = adapter + val result: FactoryAdapter = parse(source, parser) + result.rootElem.asInstanceOf[T] + } + + def loadXMLNodes(source: InputSource, parser: SAXParser): Seq[Node] = { + val result: FactoryAdapter = parse(source, parser) + result.prolog ++ (result.rootElem :: result.epilogue) + } + + private def parse(source: InputSource, parser: SAXParser): FactoryAdapter = { + val result: FactoryAdapter = adapter try { - parser.setProperty("http://xml.org/sax/properties/lexical-handler", newAdapter) + parser.setProperty("http://xml.org/sax/properties/lexical-handler", result) } catch { case _: SAXNotRecognizedException => } - newAdapter.scopeStack = TopScope :: newAdapter.scopeStack - parser.parse(source, newAdapter) - newAdapter.scopeStack = newAdapter.scopeStack.tail + result.scopeStack = TopScope :: result.scopeStack + parser.parse(source, result) + result.scopeStack = result.scopeStack.tail - newAdapter.rootElem.asInstanceOf[T] + result } /** Loads XML from the given file, file descriptor, or filename. */ @@ -80,4 +90,15 @@ trait XMLLoader[T <: Node] { /** Loads XML from the given String. */ def loadString(string: String): T = loadXML(fromString(string), parser) -} \ No newline at end of file + + /** Load XML nodes, including comments and processing instructions that precede and follow the root element. */ + def loadFileNodes(file: File): Seq[Node] = loadXMLNodes(fromFile(file), parser) + def loadFileNodes(fd: FileDescriptor): Seq[Node] = loadXMLNodes(fromFile(fd), parser) + def loadFileNodes(name: String): Seq[Node] = loadXMLNodes(fromFile(name), parser) + def loadNodes(is: InputStream): Seq[Node] = loadXMLNodes(fromInputStream(is), parser) + def loadNodes(reader: Reader): Seq[Node] = loadXMLNodes(fromReader(reader), parser) + def loadNodes(sysID: String): Seq[Node] = loadXMLNodes(fromSysId(sysID), parser) + def loadNodes(source: InputSource): Seq[Node] = loadXMLNodes(source, parser) + def loadNodes(url: URL): Seq[Node] = loadXMLNodes(fromInputStream(url.openStream()), parser) + def loadStringNodes(string: String): Seq[Node] = loadXMLNodes(fromString(string), parser) +} diff --git a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala index 1ac7e9f0..18d32633 100644 --- a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala +++ b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala @@ -40,9 +40,11 @@ trait ConsoleErrorHandler extends DefaultHandler2 { * underlying SAX parser. */ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Node] { + var prolog: List[Node] = List.empty var rootElem: Node = _ + var epilogue: List[Node] = List.empty - val buffer = new StringBuilder() + val buffer: StringBuilder = new StringBuilder() private var inCDATA: Boolean = false /** List of attributes @@ -51,28 +53,28 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod * * @since 2.0.0 */ - var attribStack = List.empty[MetaData] + var attribStack: List[MetaData] = List.empty /** List of elements * * Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]]. * * @since 2.0.0 */ - var hStack = List.empty[Node] // [ element ] contains siblings + var hStack: List[Node] = List.empty // [ element ] contains siblings /** List of element names * * Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]]. * * @since 2.0.0 */ - var tagStack = List.empty[String] + var tagStack: List[String] = List.empty /** List of namespaces * * Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]]. * * @since 2.0.0 */ - var scopeStack = List.empty[NamespaceBinding] + var scopeStack: List[NamespaceBinding] = List.empty var curTag: String = _ var capture: Boolean = false @@ -123,7 +125,7 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod // ContentHandler methods // - val normalizeWhitespace = false + val normalizeWhitespace: Boolean = false /** * Capture characters, possibly normalizing whitespace. @@ -177,13 +179,20 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod attributes: Attributes): Unit = { captureText() + + // capture the prolog at the start of the root element + if (tagStack.isEmpty) { + prolog = hStack.reverse + hStack = List.empty + } + tagStack = curTag :: tagStack curTag = qname val localName = splitName(qname)._2 capture = nodeContainsText(localName) - hStack = null :: hStack + hStack = null :: hStack var m: MetaData = Null var scpe: NamespaceBinding = if (scopeStack.isEmpty) TopScope @@ -193,7 +202,7 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod val qname = attributes getQName i val value = attributes getValue i val (pre, key) = splitName(qname) - def nullIfEmpty(s: String) = if (s == "") null else s + def nullIfEmpty(s: String): String = if (s == "") null else s if (pre == "xmlns" || (pre == null && qname == "xmlns")) { val arg = if (pre == null) null else key @@ -250,6 +259,12 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod capture = curTag != null && nodeContainsText(curTag) // root level } + override def endDocument(): Unit = { + // capture the epilogue at the end of the document + epilogue = hStack.init.reverse + hStack = hStack.last :: Nil + } + /** * Processing instruction. */ diff --git a/shared/src/main/scala/scala/xml/parsing/MarkupParser.scala b/shared/src/main/scala/scala/xml/parsing/MarkupParser.scala index acd19485..60b7b5a4 100755 --- a/shared/src/main/scala/scala/xml/parsing/MarkupParser.scala +++ b/shared/src/main/scala/scala/xml/parsing/MarkupParser.scala @@ -98,6 +98,8 @@ trait MarkupParser extends MarkupParserCommon with TokenTests { var extIndex = -1 /** holds temporary values of pos */ + // Note: this is clearly an override, but if marked as such it causes a "...cannot override a mutable variable" + // error with Scala 3; does it work with Scala 3 if not explicitly marked as an override remains to be seen... var tmppos: Int = _ /** holds the next character */ From 9243de64344e2a60b6468eb8e82041b242d06cbd Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 4 Oct 2021 16:14:17 -0600 Subject: [PATCH 22/53] AdoptOpenJDK is now Temurin --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3aa63aa3..a06efc26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - uses: coursier/cache-action@v6 - uses: actions/setup-java@v2 with: - distribution: adopt + distribution: temurin java-version: ${{matrix.java}} - name: Test run: sbt ++${{matrix.scala}} test headerCheck versionPolicyCheck package diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc337111..d69ab720 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-java@v2 with: - distribution: adopt + distribution: temurin java-version: 8 - run: sbt versionCheck ci-release env: From 95b72279d1d6732ecc4e5481eaa68b5853417975 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Sun, 10 Oct 2021 01:15:41 +0200 Subject: [PATCH 23/53] Update sbt-scalajs, scalajs-compiler, ... to 1.7.1 (#566) Co-authored-by: kenji yoshida <6b656e6a69@gmail.com> --- .circleci/config.yml | 6 +++--- project/plugins.sbt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c924784c..213a7017 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -139,15 +139,15 @@ workflows: - scalajs_job: name: sjs1.0_2.12 scala_version: 2.12.15 - scalajs_version: 1.7.0 + scalajs_version: 1.7.1 - scalajs_job: name: sjs1.0_2.13 scala_version: 2.13.6 - scalajs_version: 1.7.0 + scalajs_version: 1.7.1 - scalajs_job: name: sjs1.0_3 scala_version: 3.0.2 - scalajs_version: 1.7.0 + scalajs_version: 1.7.1 - scalanative_job: name: native0.4_2.12 scala_version: 2.12.15 diff --git a/project/plugins.sbt b/project/plugins.sbt index 32c1365e..e9e50e50 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") From 4304f69325f9e93681b3927d01cd59ab1493821f Mon Sep 17 00:00:00 2001 From: kenji yoshida <6b656e6a69@gmail.com> Date: Fri, 22 Oct 2021 12:24:56 +0900 Subject: [PATCH 24/53] remove unused settings in CircleCI config --- .circleci/config.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 213a7017..b6a7658b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,12 +60,6 @@ jobs: description: "Scala version" default: 2.12.15 type: string - scalajs_version: - description: "ScalaJS version" - default: 1.1.1 - type: string - environment: - SCALAJS_VERSION: << parameters.scalajs_version >> steps: - checkout - run: java -version @@ -80,12 +74,6 @@ jobs: description: "Scala version" default: 2.12.15 type: string - scalanative_version: - description: "Scala Native version" - default: 0.4.0 - type: string - environment: - SCALANATIVE_VERSION: << parameters.scalanative_version >> steps: - checkout - run: @@ -139,20 +127,15 @@ workflows: - scalajs_job: name: sjs1.0_2.12 scala_version: 2.12.15 - scalajs_version: 1.7.1 - scalajs_job: name: sjs1.0_2.13 scala_version: 2.13.6 - scalajs_version: 1.7.1 - scalajs_job: name: sjs1.0_3 scala_version: 3.0.2 - scalajs_version: 1.7.1 - scalanative_job: name: native0.4_2.12 scala_version: 2.12.15 - scalanative_version: 0.4.0 - scalanative_job: name: native0.4_2.13 scala_version: 2.13.6 - scalanative_version: 0.4.0 From a89e8b2029d3dea0c81536c851f6371d2ed49773 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Fri, 22 Oct 2021 15:45:55 +0200 Subject: [PATCH 25/53] Update auxlib, javalib, junit-runtime, ... to 0.4.1 (#569) Co-authored-by: kenji yoshida <6b656e6a69@gmail.com> --- build.sbt | 1 + project/plugins.sbt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index fc3906c0..20855a5b 100644 --- a/build.sbt +++ b/build.sbt @@ -36,6 +36,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) name := "scala-xml", scalaModuleAutomaticModuleName := Some("scala.xml"), crossScalaVersions := Seq("2.13.6", "2.12.15", "3.0.2"), + scalaVersion := "2.12.15", scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((3, _)) => diff --git a/project/plugins.sbt b/project/plugins.sbt index e9e50e50..a366dbc8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,5 +2,5 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.1") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") From 806d3e7f1958c92a86d337a25e473175b19dcb42 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 26 Oct 2021 07:00:48 +0200 Subject: [PATCH 26/53] Update junit-interface to 0.13.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 20855a5b..a0212a32 100644 --- a/build.sbt +++ b/build.sbt @@ -119,7 +119,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) OsgiKeys.exportPackage := Seq(s"scala.xml.*;version=${version.value}"), libraryDependencies += "junit" % "junit" % "4.13.2" % Test, - libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, + libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.2" % Test, libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.12.0" % Test, libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((3, _)) => From fed7f6a309fea76d7cbefe47aac2821534d14589 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 18 Oct 2021 15:10:54 +0200 Subject: [PATCH 27/53] Update scala3-library, ... to 3.1.0 --- .circleci/config.yml | 8 ++++---- .github/workflows/ci.yml | 2 +- build.sbt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b6a7658b..98d4999a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,7 +99,7 @@ workflows: - scala_job: name: 3.0.2 java_version: jdk8 - scala_version: 3.0.2 + scala_version: 3.1.0 - scala_job: name: jdk11_2.12 java_version: jdk11 @@ -111,7 +111,7 @@ workflows: - scala_job: name: jdk11_3.0 java_version: jdk11 - scala_version: 3.0.2 + scala_version: 3.1.0 - scala_job: name: jdk17_2.12 java_version: jdk17 @@ -123,7 +123,7 @@ workflows: - scala_job: name: jdk17_3.0 java_version: jdk17 - scala_version: 3.0.2 + scala_version: 3.1.0 - scalajs_job: name: sjs1.0_2.12 scala_version: 2.12.15 @@ -132,7 +132,7 @@ workflows: scala_version: 2.13.6 - scalajs_job: name: sjs1.0_3 - scala_version: 3.0.2 + scala_version: 3.1.0 - scalanative_job: name: native0.4_2.12 scala_version: 2.12.15 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a06efc26..1e53757e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: java: [8, 11, 17] - scala: [2.12.15, 2.13.6, 3.0.2] + scala: [2.12.15, 2.13.6, 3.1.0] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/build.sbt b/build.sbt index a0212a32..5880d1a0 100644 --- a/build.sbt +++ b/build.sbt @@ -35,7 +35,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings( name := "scala-xml", scalaModuleAutomaticModuleName := Some("scala.xml"), - crossScalaVersions := Seq("2.13.6", "2.12.15", "3.0.2"), + crossScalaVersions := Seq("2.13.6", "2.12.15", "3.0.2", "3.1.0"), scalaVersion := "2.12.15", scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { From c8aca30855f934d66aa0ab1dcd7d5ffbf58e89c5 Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Tue, 2 Nov 2021 21:32:23 -0400 Subject: [PATCH 28/53] Add 3.1.0 to build but disable publish --- .circleci/config.yml | 15 +++++++++++++++ .github/workflows/ci.yml | 2 +- build.sbt | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 98d4999a..b490dc56 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,6 +99,10 @@ workflows: - scala_job: name: 3.0.2 java_version: jdk8 + scala_version: 3.0.2 + - scala_job: + name: 3.1.0 + java_version: jdk8 scala_version: 3.1.0 - scala_job: name: jdk11_2.12 @@ -111,6 +115,10 @@ workflows: - scala_job: name: jdk11_3.0 java_version: jdk11 + scala_version: 3.0.2 + - scala_job: + name: jdk11_3.1 + java_version: jdk11 scala_version: 3.1.0 - scala_job: name: jdk17_2.12 @@ -123,6 +131,10 @@ workflows: - scala_job: name: jdk17_3.0 java_version: jdk17 + scala_version: 3.0.2 + - scala_job: + name: jdk17_3.1 + java_version: jdk17 scala_version: 3.1.0 - scalajs_job: name: sjs1.0_2.12 @@ -132,6 +144,9 @@ workflows: scala_version: 2.13.6 - scalajs_job: name: sjs1.0_3 + scala_version: 3.0.2 + - scalajs_job: + name: sjs1.0_3.1 scala_version: 3.1.0 - scalanative_job: name: native0.4_2.12 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e53757e..b12acfcb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: java: [8, 11, 17] - scala: [2.12.15, 2.13.6, 3.1.0] + scala: [2.12.15, 2.13.6, 3.0.2, 3.1.0] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/build.sbt b/build.sbt index 5880d1a0..8c019f4b 100644 --- a/build.sbt +++ b/build.sbt @@ -38,6 +38,12 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) crossScalaVersions := Seq("2.13.6", "2.12.15", "3.0.2", "3.1.0"), scalaVersion := "2.12.15", + // Don't publish for Scala 3.1 or later, only from 3.0 + publish / skip := (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((3, x)) if x > 0 => true + case _ => false + }), + scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((3, _)) => Seq("-language:Scala2") From 1bcd9a1ecce959249a2b84caf78b8416ba420ad1 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 17 Nov 2021 06:44:58 -0800 Subject: [PATCH 29/53] Update scala-compiler, scala-library to 2.13.7 --- .circleci/config.yml | 12 ++++++------ .github/workflows/ci.yml | 2 +- build.sbt | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b490dc56..692ba727 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -93,9 +93,9 @@ workflows: java_version: jdk8 scala_version: 2.12.15 - scala_job: - name: 2.13.6 + name: 2.13.7 java_version: jdk8 - scala_version: 2.13.6 + scala_version: 2.13.7 - scala_job: name: 3.0.2 java_version: jdk8 @@ -111,7 +111,7 @@ workflows: - scala_job: name: jdk11_2.13 java_version: jdk11 - scala_version: 2.13.6 + scala_version: 2.13.7 - scala_job: name: jdk11_3.0 java_version: jdk11 @@ -127,7 +127,7 @@ workflows: - scala_job: name: jdk17_2.13 java_version: jdk17 - scala_version: 2.13.6 + scala_version: 2.13.7 - scala_job: name: jdk17_3.0 java_version: jdk17 @@ -141,7 +141,7 @@ workflows: scala_version: 2.12.15 - scalajs_job: name: sjs1.0_2.13 - scala_version: 2.13.6 + scala_version: 2.13.7 - scalajs_job: name: sjs1.0_3 scala_version: 3.0.2 @@ -153,4 +153,4 @@ workflows: scala_version: 2.12.15 - scalanative_job: name: native0.4_2.13 - scala_version: 2.13.6 + scala_version: 2.13.7 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b12acfcb..c273e5f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: java: [8, 11, 17] - scala: [2.12.15, 2.13.6, 3.0.2, 3.1.0] + scala: [2.12.15, 2.13.7, 3.0.2, 3.1.0] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/build.sbt b/build.sbt index 8c019f4b..c89e5665 100644 --- a/build.sbt +++ b/build.sbt @@ -35,7 +35,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings( name := "scala-xml", scalaModuleAutomaticModuleName := Some("scala.xml"), - crossScalaVersions := Seq("2.13.6", "2.12.15", "3.0.2", "3.1.0"), + crossScalaVersions := Seq("2.13.7", "2.12.15", "3.0.2", "3.1.0"), scalaVersion := "2.12.15", // Don't publish for Scala 3.1 or later, only from 3.0 @@ -140,7 +140,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .jsEnablePlugins(ScalaJSJUnitPlugin) .nativeSettings( - crossScalaVersions := Seq("2.13.6", "2.12.15"), + crossScalaVersions := Seq("2.13.7", "2.12.15"), // Scala Native cannot run forked tests Test / fork := false, libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test, From 08a688a284cdd668f882e7049ada428e1108817d Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Wed, 17 Nov 2021 13:13:02 -0500 Subject: [PATCH 30/53] Set the Circle instance size to small --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 692ba727..8efb8dff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,12 +4,15 @@ executors: scala_jdk8_executor: docker: - image: circleci/openjdk:8-jdk-node + resource_class: small scala_jdk11_executor: docker: - image: circleci/openjdk:11-jdk + resource_class: small scala_jdk17_executor: docker: - image: circleci/openjdk:17-buster + resource_class: small commands: sbt_cmd: From 1be3ad113a09a49dd68221dc4b7672649ddc89ea Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 8 Dec 2021 03:28:04 +0100 Subject: [PATCH 31/53] Update scala-native to 0.4.2 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index a366dbc8..1d78d5c8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,5 +2,5 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.1") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.2") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") From 0c6b20ccd279deb0d68369c8f05753304cd466a5 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 11 Dec 2021 04:00:27 +0100 Subject: [PATCH 32/53] Update sbt to 1.5.6 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 10fd9eee..bb3a9b7d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=1.5.6 From 441678d23c79cf36723ab1fd8c57d3fb7ca0ea06 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 11 Dec 2021 04:00:18 +0100 Subject: [PATCH 33/53] Update sbt-scalajs, scalajs-compiler, ... to 1.8.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 1d78d5c8..c99c6bc1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.2") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") From d0bc150a087af6d9bb8e85d3aec180318429778f Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 16 Dec 2021 11:14:22 +0100 Subject: [PATCH 34/53] Update sbt to 1.5.7 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index bb3a9b7d..baf5ff3e 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.6 +sbt.version=1.5.7 From 03e78086f19b8f20bd793bedf3d324aca05d7ccd Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 22 Dec 2021 03:45:50 +0100 Subject: [PATCH 35/53] Update sbt to 1.5.8 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index baf5ff3e..e64c208f 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.7 +sbt.version=1.5.8 From e56a3af29e16cad7e61808918af6cab6b7073bcc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 27 Dec 2021 08:35:38 +0100 Subject: [PATCH 36/53] Update sbt to 1.6.0 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index e64c208f..1e70b0c1 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.8 +sbt.version=1.6.0 From 92f4d42f74a875f9f5f8ba1b347a0fafd2073cb1 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 30 Dec 2021 02:19:31 +0100 Subject: [PATCH 37/53] Update sbt to 1.6.1 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 1e70b0c1..3161d214 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.6.0 +sbt.version=1.6.1 From a2e83c1719566606c0dc0a0160ad8d08f890e92e Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Wed, 5 Jan 2022 13:58:02 -0500 Subject: [PATCH 38/53] Drop .conf file for Scalafmt --- .scalafmt.conf | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .scalafmt.conf diff --git a/.scalafmt.conf b/.scalafmt.conf deleted file mode 100644 index ffbdff9f..00000000 --- a/.scalafmt.conf +++ /dev/null @@ -1 +0,0 @@ -version = "2.7.4" From b680f3ce095cdf23cb5ddc6fe8a2365a2df1aca0 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 30 Dec 2021 02:19:24 +0100 Subject: [PATCH 39/53] Update junit-interface to 0.13.3 Co-authored-by: Aaron S. Hawley --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c89e5665..8062669f 100644 --- a/build.sbt +++ b/build.sbt @@ -125,7 +125,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) OsgiKeys.exportPackage := Seq(s"scala.xml.*;version=${version.value}"), libraryDependencies += "junit" % "junit" % "4.13.2" % Test, - libraryDependencies += "com.github.sbt" % "junit-interface" % "0.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, _)) => From 61f888ce6f3891ff55ca1a15c5a913e46ac2ae07 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Wed, 5 Jan 2022 16:08:58 -0800 Subject: [PATCH 40/53] copyright 2022 --- NOTICE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NOTICE b/NOTICE index 006f1608..2d345d83 100644 --- a/NOTICE +++ b/NOTICE @@ -1,6 +1,6 @@ scala-xml -Copyright (c) 2002-2021 EPFL -Copyright (c) 2011-2021 Lightbend, Inc. +Copyright (c) 2002-2022 EPFL +Copyright (c) 2011-2022 Lightbend, Inc. scala-xml includes software developed at LAMP/EPFL (https://lamp.epfl.ch/) and From 363ac3131c24465bd2ea9aceac813c47835b7c1e Mon Sep 17 00:00:00 2001 From: Leonid Dubinsky Date: Fri, 7 Jan 2022 00:02:12 -0500 Subject: [PATCH 41/53] Handle XML namespace declarations even when the underlying parser is namespace-aware. fixes #506 --- jvm/src/test/scala/scala/xml/XMLTest.scala | 29 +++++++++++++++++++ .../scala/xml/parsing/FactoryAdapter.scala | 15 ++++++++++ 2 files changed, 44 insertions(+) diff --git a/jvm/src/test/scala/scala/xml/XMLTest.scala b/jvm/src/test/scala/scala/xml/XMLTest.scala index e7f3624f..3f6eb62e 100644 --- a/jvm/src/test/scala/scala/xml/XMLTest.scala +++ b/jvm/src/test/scala/scala/xml/XMLTest.scala @@ -629,6 +629,35 @@ class XMLTestJVM { // does not work: roundtripNodes(" ") } + // using non-namespace-aware parser, this always worked; + // using namespace-aware parser, this works with FactoryAdapter enhanced to handle startPrefixMapping() events; + // see https://github.com/scala/scala-xml/issues/506 + def roundtrip(namespaceAware: Boolean, xml: String): Unit = { + val parserFactory: javax.xml.parsers.SAXParserFactory = javax.xml.parsers.SAXParserFactory.newInstance() + parserFactory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true) + parserFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false) + parserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true) + parserFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false) + parserFactory.setFeature("http://xml.org/sax/features/external-general-entities", false) + parserFactory.setFeature("http://xml.org/sax/features/resolve-dtd-uris", false) + parserFactory.setNamespaceAware(namespaceAware) + parserFactory.setXIncludeAware(namespaceAware) + + assertEquals(xml, XML.withSAXParser(parserFactory.newSAXParser()).loadString(xml).toString()) + } + + @UnitTest + def namespaceUnaware: Unit = + roundtrip(namespaceAware = false, """""") + + @UnitTest + def namespaceAware: Unit = + roundtrip(namespaceAware = true, """""") + + @UnitTest + def namespaceAware2: Unit = + roundtrip(namespaceAware = true, """""") + @UnitTest def nodeSeqNs: Unit = { val x = { diff --git a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala index 18d32633..eaa43afd 100644 --- a/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala +++ b/shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala @@ -211,10 +211,25 @@ abstract class FactoryAdapter extends DefaultHandler2 with factory.XMLLoader[Nod m = Attribute(Option(pre), key, Text(value), m) } + // Add namespace bindings for the prefix mappings declared by this element + // (if there are any, the parser is namespace-aware, and no namespace bindings were delivered as attributes). + // All `startPrefixMapping()` events will occur immediately before the corresponding `startElement()` event. + for ((prefix: String, uri: String) <- prefixMappings) + scpe = NamespaceBinding(if (prefix.isEmpty) null else prefix, uri, scpe) + + // Once the `prefixMappings` are processed into `scpe`, the list is emptied out + // so that already-declared namespaces are not re-declared on the nested elements. + prefixMappings = List.empty + scopeStack = scpe :: scopeStack attribStack = m :: attribStack } + private var prefixMappings: List[(String, String)] = List.empty + + override def startPrefixMapping(prefix: String, uri: String): Unit = + prefixMappings = (prefix, uri) :: prefixMappings + /** * Captures text or cdata. */ From 44f7478186ed22c2659362054c1c4d1c31816db6 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 6 Jan 2022 09:09:42 +0100 Subject: [PATCH 42/53] Update sbt-scala-module to 3.0.1 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index c99c6bc1..4f781072 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") From cb59e9946473d2fb4b55db0b345edd1c4d0f4952 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 13 Jan 2022 11:23:10 +0100 Subject: [PATCH 43/53] Update scala-compiler, scala-library to 2.13.8 --- .circleci/config.yml | 12 ++++++------ .github/workflows/ci.yml | 2 +- build.sbt | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8efb8dff..ea99f344 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -96,9 +96,9 @@ workflows: java_version: jdk8 scala_version: 2.12.15 - scala_job: - name: 2.13.7 + name: 2.13.8 java_version: jdk8 - scala_version: 2.13.7 + scala_version: 2.13.8 - scala_job: name: 3.0.2 java_version: jdk8 @@ -114,7 +114,7 @@ workflows: - scala_job: name: jdk11_2.13 java_version: jdk11 - scala_version: 2.13.7 + scala_version: 2.13.8 - scala_job: name: jdk11_3.0 java_version: jdk11 @@ -130,7 +130,7 @@ workflows: - scala_job: name: jdk17_2.13 java_version: jdk17 - scala_version: 2.13.7 + scala_version: 2.13.8 - scala_job: name: jdk17_3.0 java_version: jdk17 @@ -144,7 +144,7 @@ workflows: scala_version: 2.12.15 - scalajs_job: name: sjs1.0_2.13 - scala_version: 2.13.7 + scala_version: 2.13.8 - scalajs_job: name: sjs1.0_3 scala_version: 3.0.2 @@ -156,4 +156,4 @@ workflows: scala_version: 2.12.15 - scalanative_job: name: native0.4_2.13 - scala_version: 2.13.7 + scala_version: 2.13.8 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c273e5f9..205a47f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: java: [8, 11, 17] - scala: [2.12.15, 2.13.7, 3.0.2, 3.1.0] + scala: [2.12.15, 2.13.8, 3.0.2, 3.1.0] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/build.sbt b/build.sbt index 8062669f..e7113a38 100644 --- a/build.sbt +++ b/build.sbt @@ -35,7 +35,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings( name := "scala-xml", scalaModuleAutomaticModuleName := Some("scala.xml"), - crossScalaVersions := Seq("2.13.7", "2.12.15", "3.0.2", "3.1.0"), + crossScalaVersions := Seq("2.13.8", "2.12.15", "3.0.2", "3.1.0"), scalaVersion := "2.12.15", // Don't publish for Scala 3.1 or later, only from 3.0 @@ -140,7 +140,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .jsEnablePlugins(ScalaJSJUnitPlugin) .nativeSettings( - crossScalaVersions := Seq("2.13.7", "2.12.15"), + crossScalaVersions := Seq("2.13.8", "2.12.15"), // Scala Native cannot run forked tests Test / fork := false, libraryDependencies += "org.scala-native" %%% "junit-runtime" % nativeVersion % Test, From 302309d11c22c34e4182ddda8e15962d9f07747d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 22 Jan 2022 14:45:40 +0100 Subject: [PATCH 44/53] Update auxlib, javalib, junit-runtime, ... to 0.4.3 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4f781072..0950c600 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,5 +2,5 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.2") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") From a41c06bc7c6cfd89c26dd5d6de8f55422bf7d595 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Wed, 5 Jan 2022 15:00:09 +0900 Subject: [PATCH 45/53] support scala-native Scala 3 build --- .circleci/config.yml | 3 ++ build.sbt | 76 +++++++++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ea99f344..27d9cb30 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -157,3 +157,6 @@ workflows: - scalanative_job: name: native0.4_2.13 scala_version: 2.13.8 + - scalanative_job: + name: native0.4_3 + scala_version: 3.1.0 diff --git a/build.sbt b/build.sbt index e7113a38..ae66be95 100644 --- a/build.sbt +++ b/build.sbt @@ -140,26 +140,66 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .jsEnablePlugins(ScalaJSJUnitPlugin) .nativeSettings( - crossScalaVersions := Seq("2.13.8", "2.12.15"), + crossScalaVersions := Seq("2.13.8", "2.12.15", "3.1.0"), + mimaPreviousArtifacts := { + // TODO remove this setting whien 2.0.2 released + if (scalaBinaryVersion.value == "3") { + mimaPreviousArtifacts.value.filterNot(_.revision == "2.0.1") + } else { + mimaPreviousArtifacts.value + } + }, // 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" + Seq(Compile, Test).map { s => + s / sources := { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((3, 0)) => + Nil + case _ => + (s / sources).value + } + } + }, + libraryDependencies := { + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((3, 0)) => + // scala-native does not support Scala 3.0.x + Nil + case _ => + libraryDependencies.value ++ Seq("org.scala-native" %%% "junit-runtime" % nativeVersion % Test) + } + }, + Compile / doc / scalacOptions --= { + // TODO remove this workaround + // https://github.com/scala-native/scala-native/issues/2503 + if (scalaBinaryVersion.value == "3") { + (Compile / doc / scalacOptions).value.filter(_.contains("-Xplugin")) + } else { + Nil + } + }, + publish / skip := CrossVersion.partialVersion(scalaVersion.value) == Some((3, 0)), + Test / scalacOptions ++= { + if (CrossVersion.partialVersion(scalaVersion.value) != Some((3, 0))) { + 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")) + Seq(s"-Xplugin:$jarPath") + } else { + Nil + } }, Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v") ) From 6ca657798b164b2da5d3ab0a3e7e2b927c9a7761 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 2 Feb 2022 07:54:41 +0100 Subject: [PATCH 46/53] Update scala3-library, ... to 3.1.1 --- .circleci/config.yml | 8 ++++---- .github/workflows/ci.yml | 2 +- build.sbt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ea99f344..728211ad 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -106,7 +106,7 @@ workflows: - scala_job: name: 3.1.0 java_version: jdk8 - scala_version: 3.1.0 + scala_version: 3.1.1 - scala_job: name: jdk11_2.12 java_version: jdk11 @@ -122,7 +122,7 @@ workflows: - scala_job: name: jdk11_3.1 java_version: jdk11 - scala_version: 3.1.0 + scala_version: 3.1.1 - scala_job: name: jdk17_2.12 java_version: jdk17 @@ -138,7 +138,7 @@ workflows: - scala_job: name: jdk17_3.1 java_version: jdk17 - scala_version: 3.1.0 + scala_version: 3.1.1 - scalajs_job: name: sjs1.0_2.12 scala_version: 2.12.15 @@ -150,7 +150,7 @@ workflows: scala_version: 3.0.2 - scalajs_job: name: sjs1.0_3.1 - scala_version: 3.1.0 + scala_version: 3.1.1 - scalanative_job: name: native0.4_2.12 scala_version: 2.12.15 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 205a47f0..7ce10f23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: java: [8, 11, 17] - scala: [2.12.15, 2.13.8, 3.0.2, 3.1.0] + scala: [2.12.15, 2.13.8, 3.0.2, 3.1.1] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/build.sbt b/build.sbt index e7113a38..37bfb95e 100644 --- a/build.sbt +++ b/build.sbt @@ -35,7 +35,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings( name := "scala-xml", scalaModuleAutomaticModuleName := Some("scala.xml"), - crossScalaVersions := Seq("2.13.8", "2.12.15", "3.0.2", "3.1.0"), + crossScalaVersions := Seq("2.13.8", "2.12.15", "3.0.2", "3.1.1"), scalaVersion := "2.12.15", // Don't publish for Scala 3.1 or later, only from 3.0 From 719bd3172d6669b65a9895ec01b3a880d64467e8 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 2 Feb 2022 07:54:44 +0100 Subject: [PATCH 47/53] Update sbt to 1.6.2 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 3161d214..c8fcab54 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.6.1 +sbt.version=1.6.2 From 3378b026cbffa6416ea7fc43ec5fc254cd145045 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 3 Feb 2022 14:15:11 +0100 Subject: [PATCH 48/53] Skip tasks with Scala Native / Scala 3.0 - Update Scala Native Scala 3 version to 3.1.1 --- .circleci/config.yml | 2 +- build.sbt | 86 ++++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 52 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 27d9cb30..34b80553 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -159,4 +159,4 @@ workflows: scala_version: 2.13.8 - scalanative_job: name: native0.4_3 - scala_version: 3.1.0 + scala_version: 3.1.1 diff --git a/build.sbt b/build.sbt index ae66be95..74f5d5b5 100644 --- a/build.sbt +++ b/build.sbt @@ -140,7 +140,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .jsEnablePlugins(ScalaJSJUnitPlugin) .nativeSettings( - crossScalaVersions := Seq("2.13.8", "2.12.15", "3.1.0"), + crossScalaVersions := Seq("2.13.8", "2.12.15", "3.1.1"), mimaPreviousArtifacts := { // TODO remove this setting whien 2.0.2 released if (scalaBinaryVersion.value == "3") { @@ -151,55 +151,39 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) }, // Scala Native cannot run forked tests Test / fork := false, - Seq(Compile, Test).map { s => - s / sources := { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((3, 0)) => - Nil - case _ => - (s / sources).value - } - } - }, - libraryDependencies := { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((3, 0)) => - // scala-native does not support Scala 3.0.x - Nil - case _ => - libraryDependencies.value ++ Seq("org.scala-native" %%% "junit-runtime" % nativeVersion % Test) - } - }, - Compile / doc / scalacOptions --= { - // TODO remove this workaround - // https://github.com/scala-native/scala-native/issues/2503 - if (scalaBinaryVersion.value == "3") { - (Compile / doc / scalacOptions).value.filter(_.contains("-Xplugin")) - } else { - Nil - } - }, - publish / skip := CrossVersion.partialVersion(scalaVersion.value) == Some((3, 0)), - Test / scalacOptions ++= { - if (CrossVersion.partialVersion(scalaVersion.value) != Some((3, 0))) { - 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")) - Seq(s"-Xplugin:$jarPath") - } else { - Nil - } + 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") + Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-s", "-v"), + // Scala Native doesn't support Scala 3.0 + Compile / nativeLink := { if(isScala30(scalaVersion.value)) null else (Compile / nativeLink).value }, + Test / nativeLink := { if(isScala30(scalaVersion.value)) null else (Test / nativeLink).value }, + Test / test := { if(isScala30(scalaVersion.value)) {} else (Test / test).value }, + Compile / sources := { if(isScala30(scalaVersion.value)) Nil else (Compile / sources).value }, + Test / sources := { if(isScala30(scalaVersion.value)) Nil else (Test / sources).value }, + libraryDependencies := { if(isScala30(scalaVersion.value)) Nil else libraryDependencies.value }, + Test / scalacOptions := { if(isScala30(scalaVersion.value)) Nil else (Test / scalacOptions).value }, + publish / skip := { isScala30(scalaVersion.value) }, ) + +def isScala30(scalaVersion: String) = { + CrossVersion.partialVersion(scalaVersion) match { + case Some((3, 0)) => true + case _ => false + } +} From 114b22e2e491c534f8bfac9d06d13014a434bbfa Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 7 Feb 2022 10:53:14 +0100 Subject: [PATCH 49/53] Update sbt-header to 5.6.5 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 0950c600..42de6746 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,4 +3,4 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5") From 29c758cc6c58b6d558632e2cc5e2bc237dfa98a7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 15 Feb 2022 05:34:32 +0100 Subject: [PATCH 50/53] Update sbt-scalajs, scalajs-compiler, ... to 1.9.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 0950c600..a50e20ae 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") From 21f5a61ea3d7d8e81aa0f2fbc8674cb5f3c0e665 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 3 Mar 2022 19:10:58 +0100 Subject: [PATCH 51/53] Update auxlib, javalib, junit-runtime, ... to 0.4.4 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 2c511a0c..177cea08 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,5 +2,5 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5") From 5bee75b7f40a7272716858f3d8e5585c4c9a29ee Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 14 Mar 2022 17:31:23 +0100 Subject: [PATCH 52/53] Fix typo in build.sbt Co-authored-by: Eric K Richardson --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 74f5d5b5..41a77e83 100644 --- a/build.sbt +++ b/build.sbt @@ -142,7 +142,7 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) .nativeSettings( crossScalaVersions := Seq("2.13.8", "2.12.15", "3.1.1"), mimaPreviousArtifacts := { - // TODO remove this setting whien 2.0.2 released + // TODO remove this setting when 2.0.2 released if (scalaBinaryVersion.value == "3") { mimaPreviousArtifacts.value.filterNot(_.revision == "2.0.1") } else { From f553bee67027fbd1a366262cf5b864fe1567aebb Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 22 Mar 2022 19:22:32 +0100 Subject: [PATCH 53/53] Update sbt-scala-native-crossproject, ... to 1.2.0 --- project/plugins.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 177cea08..1f04c724 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.1") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") -addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5")