Skip to content

Commit 80befd6

Browse files
authored
Update Scala to 2.12.18 (#277)
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.
1 parent 801746a commit 80befd6

File tree

4 files changed

+632
-11
lines changed

4 files changed

+632
-11
lines changed

polyglot-scala/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
<name>Polyglot :: Scala</name>
2121

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

2827
<contributors>
@@ -45,10 +44,16 @@
4544

4645
<dependency>
4746
<groupId>com.twitter</groupId>
48-
<artifactId>util-eval_${scala.bin.version}</artifactId>
47+
<artifactId>util-core_${scala.bin.version}</artifactId>
4948
<version>6.43.0</version>
5049
</dependency>
5150

51+
<dependency>
52+
<groupId>org.scala-lang.modules</groupId>
53+
<artifactId>scala-xml_${scala.bin.version}</artifactId>
54+
<version>1.0.6</version>
55+
</dependency>
56+
5257
<dependency>
5358
<groupId>com.googlecode.kiama</groupId>
5459
<artifactId>kiama_${scala.bin.version}</artifactId>
@@ -98,7 +103,7 @@
98103
<plugin>
99104
<groupId>net.alchim31.maven</groupId>
100105
<artifactId>scala-maven-plugin</artifactId>
101-
<version>4.8.0</version>
106+
<version>4.8.1</version>
102107
<executions>
103108
<execution>
104109
<goals>

polyglot-scala/src/it/java-and-scala-project-MavenModel/pom.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ Model(
66
name = "Test for Java + Scala compilation",
77
description = "Test for Java + Scala compilation",
88
dependencies = Seq(
9-
"org.scala-lang" % "scala-library" % "2.12.15"
9+
"org.scala-lang" % "scala-library" % "2.12.18"
1010
),
1111
build = Build(
1212
pluginManagement = PluginManagement(
1313
plugins = Seq(
1414
Plugin(
15-
"net.alchim31.maven" % "scala-maven-plugin" % "4.3.1"
15+
"net.alchim31.maven" % "scala-maven-plugin" % "4.8.1"
1616
),
1717
Plugin(
18-
"org.apache.maven.plugins" % "maven-compiler-plugin" % "2.0.2"
18+
"org.apache.maven.plugins" % "maven-compiler-plugin" % "3.11.0"
1919
)
2020
)
2121
),
2222
plugins = Seq(
2323
Plugin(
24-
"net.alchim31.maven" % "scala-maven-plugin" % "4.3.1",
24+
"net.alchim31.maven" % "scala-maven-plugin" % "4.8.1",
2525
executions = Seq(
2626
Execution(
2727
id = "scala-compile-first",

polyglot-scala/src/main/scala/org/sonatype/maven/polyglot/scala/ScalaModelReader.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.collection.immutable
1111
import scala.language.implicitConversions
1212

1313
import com.twitter.io.StreamIO
14-
import com.twitter.util.Eval
14+
import org.sonatype.maven.polyglot.scala.eval.Eval
1515

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

0 commit comments

Comments
 (0)