Skip to content

Commit

Permalink
Update Scala to 2.12.18 (#277)
Browse files Browse the repository at this point in the history
Due to some security vulnerabilities in Scala 2.11 compiler, I switched `polyglot-scala` to Scala 2.12, which is the last version, for which there is a release of `com.twitter:util-eval`, which we use to compile and evaluate the `pom.scala` files.

Unfortunately, `util-eval` throws runtime exceptions when used as-is, which is mostly due to internal changes in the Scala compiler. Since `util-eval` doesn't work with Scala 2.12 and was even removed upstream for quite some time, I vendored the single file `Eval.scala` and applied some small refactorings to make it work. The imported file was licensed under the Apache Licence, version 2, which is identical to this project license.

Due to the version bump from Scala 2.11 to 2.12, I'd consider this pull request a breaking change. The next release number for polyglot(-scala) should be therefore `0.6.0` (if we apply early semantic versioning).

* Fix #276

I think it's worth investigating, whether we can follow up with a bump to Scala 2.13. I haven't tested it yet, due to some dependencies not available. But it looks like `com.googlecode.kiama` has moved to https://github.com/inkytonik/kiama, so there should be no blockers. But the `Eval` might break again due to expected compiler changes.
  • Loading branch information
lefou authored Nov 4, 2023
1 parent 801746a commit 80befd6
Show file tree
Hide file tree
Showing 4 changed files with 632 additions and 11 deletions.
15 changes: 10 additions & 5 deletions polyglot-scala/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
<name>Polyglot :: Scala</name>

<properties>
<!-- We cannot use 2.12+, as Maven 3.x requires us to run on Java7 -->
<scala.version>2.11.12</scala.version>
<scala.bin.version>2.11</scala.bin.version>
<scala.version>2.12.18</scala.version>
<scala.bin.version>2.12</scala.bin.version>
</properties>

<contributors>
Expand All @@ -45,10 +44,16 @@

<dependency>
<groupId>com.twitter</groupId>
<artifactId>util-eval_${scala.bin.version}</artifactId>
<artifactId>util-core_${scala.bin.version}</artifactId>
<version>6.43.0</version>
</dependency>

<dependency>
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-xml_${scala.bin.version}</artifactId>
<version>1.0.6</version>
</dependency>

<dependency>
<groupId>com.googlecode.kiama</groupId>
<artifactId>kiama_${scala.bin.version}</artifactId>
Expand Down Expand Up @@ -98,7 +103,7 @@
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.8.0</version>
<version>4.8.1</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ Model(
name = "Test for Java + Scala compilation",
description = "Test for Java + Scala compilation",
dependencies = Seq(
"org.scala-lang" % "scala-library" % "2.12.15"
"org.scala-lang" % "scala-library" % "2.12.18"
),
build = Build(
pluginManagement = PluginManagement(
plugins = Seq(
Plugin(
"net.alchim31.maven" % "scala-maven-plugin" % "4.3.1"
"net.alchim31.maven" % "scala-maven-plugin" % "4.8.1"
),
Plugin(
"org.apache.maven.plugins" % "maven-compiler-plugin" % "2.0.2"
"org.apache.maven.plugins" % "maven-compiler-plugin" % "3.11.0"
)
)
),
plugins = Seq(
Plugin(
"net.alchim31.maven" % "scala-maven-plugin" % "4.3.1",
"net.alchim31.maven" % "scala-maven-plugin" % "4.8.1",
executions = Seq(
Execution(
id = "scala-compile-first",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scala.collection.immutable
import scala.language.implicitConversions

import com.twitter.io.StreamIO
import com.twitter.util.Eval
import org.sonatype.maven.polyglot.scala.eval.Eval

import java.io._
import java.util
Expand Down Expand Up @@ -260,7 +260,7 @@ class ScalaModelReader @Inject() (executeManager: ExecuteManager) extends ModelR
try {
eval.apply[ScalaModel](sourcePomFile)
} catch {
case e: eval.CompilerException =>
case e: Eval.CompilerException =>
// ModuleParseException is able to provide exact position (line nr., column nr.), so if later
// versions of CompilerException make those information available, we should map them here (instead of zeros).
// Currently, the information is only available as text in the exeception message.
Expand Down
Loading

0 comments on commit 80befd6

Please sign in to comment.