Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Scala v2.13 #425

Merged
merged 1 commit into from
Feb 27, 2021
Merged

Upgrade to Scala v2.13 #425

merged 1 commit into from
Feb 27, 2021

Conversation

rtyley
Copy link
Owner

@rtyley rtyley commented Feb 13, 2021

Key challenges with the upgrade:

  • The scala-io library is not available for Scala 2.13 (I had custom-built the Scala 2.12 version, but it was too much effort to get it to 2.13). scala-io was providing several useful features:
    • streaming reading of character data with line-splitting that preserves line-breaks (because I don't want the BFG to change the line-breaks in your files while doing --replace-text). Finding a replacement library to do this wasn't easy - so much code seems to be based on java.io.BufferedReader, which throws line-breaks away. java.util.Scanner can maybe do it, but I couldn't get it to work! In the end, I implemented my own solution, a tiny library with a fairly decent set of tests: https://github.com/rtyley/line-break-preserving-line-splitting
    • resource management - mostly replaced by using Scala 2.13's Using.
    • File-path types and operations - mostly now performed by java.nio & Guava functions.
  • Scala 2.13 has a revised collections framework, so:
    • BFG has its own ConcurrentSet which needs to be implemented in the new fashion
    • Traversable becomes Iterable, etc

@@ -13,6 +13,10 @@ object Dependencies {
// the 1.7.2 here matches slf4j-api in jgit's dependencies
val slf4jSimple = "org.slf4j" % "slf4j-simple" % "1.7.2"

val scalaCollectionPlus = "com.madgag" %% "scala-collection-plus" % "0.5"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/rtyley/scala-collection-plus, which provides mapV & groupUp

Comment on lines 76 to 80
override def clear(): Unit = ???

override def result(): ConcurrentSet[A] = ???

override def addOne(elem: A): ConcurrentSetBuilder.this.type = ???
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit dodge

@rtyley rtyley force-pushed the upgrade-to-scala-v2.13 branch 6 times, most recently from 52fa084 to e55c037 Compare February 15, 2021 20:38
@rtyley rtyley force-pushed the upgrade-to-scala-v2.13 branch 3 times, most recently from 88869f7 to 87e4de2 Compare February 27, 2021 11:36
Key challenges with the upgrade:

* The [`scala-io`](https://github.com/jesseeichar/scala-io) library is not
  available for Scala 2.13 (I had custom-built the Scala 2.12 version, but it
  was too much effort to get it to 2.13). `scala-io` was providing several
  useful features:
  * streaming reading of character data with line-splitting that *preserves
    line-breaks* (because I don't want the BFG to change the line-breaks in
    your files while doing `--replace-text`). Finding a replacement library to
    do this wasn't easy - so much code seems to be based on
    `java.io.BufferedReader`, which throws line-breaks away. `java.util.Scanner`    can _maybe_ do it, but I couldn't get it to work! In the end, I implemented
    my own solution, a tiny library with a fairly decent set of tests:
    https://github.com/rtyley/line-break-preserving-line-splitting
  * resource management - mostly replaced by using Scala 2.13's
    [`Using`](https://www.scala-lang.org/api/current/scala/util/Using$.html).
  * File-path types and operations - mostly now performed by java.nio & Guava
    functions.
* Scala 2.13 has a [revised collections framework](https://docs.scala-lang.org/overviews/core/collections-migration-213.html), so:
  * BFG has its own `ConcurrentSet` which needs to be implemented in the new
    fashion
  * `Traversable` becomes `Iterable`, etc
@rtyley rtyley merged commit 799527f into master Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant