I'm attempting to upgrade from scala 2.12 to 2.13....
# general
f
I'm attempting to upgrade from scala 2.12 to 2.13. Continuing in a thread…
When following the directions for "Enabling semantic rewrites" here: https://v1.pantsbuild.org/scala.html And then running:
Copy code
./pants compile products/datalogue/anduin/server/test/scala/io/datalogue/anduin/server:anduin
I get the output with error:
Copy code
00:29:14 [INFO] initializing pantsd...
00:29:15 [INFO] pantsd initialized.
00:29:16 [WARN] Unmatched glob from products/datalogue/anduin/plugins/hadoop/main/java/org/apache/parquet/tools:tools's `sources` field: "products/datalogue/anduin/plugins/hadoop/main/java/org/apache/parquet/tools/*.scala"
00:29:16 [ERROR] Build graph construction failed: ExecutionError 1 Exception encountered:

  MappingError: Failed to parse BUILD.tools:
SyntaxError('invalid syntax', ('<string>', 49, 15, 'SCALA_REV=2.11.12\n'))

(Use --print-exception-stacktrace to see more error details.)
I'm new to pants, so maybe there's something simple I'm missing.
h
Hi Todd 🙂 Are you able to share the BUILD file? This error means that the Python in the BUILD file was not parsable by the Python interpreter
f
Copy code
jar_library(name='scalac-plugin-dep',
            jars=[
                scala_jar(org='com.github.ghik', name='silencer-plugin', rev='1.4.2'),
                scala_jar(org='org.typelevel', name='kind-projector', rev='0.10.3'),
                scala_jar(org='com.olegpy', name='better-monadic-for', rev='0.3.1')
            ])

scala_version = '2.12.12'
jar_library(
    name='scala-library',
    jars=[
        jar(org='org.scala-lang', name='scala-library', rev=scala_version)
    ])

jar_library(
    name='scalac',
    jars=[
        jar(org='org.scala-lang', name='scala-compiler', rev=scala_version)
    ])

jar_library(
    name='scalafmt',
    jars=[
        jar(org='org.scalameta', name='scalafmt-cli_2.12', rev='2.7.5')
    ])

jar_library(
    name='scalapbc',
    jars=[
        scala_jar('com.thesamet.scalapb', 'scalapbc', '0.11.1'),
        scala_jar('org.typelevel', 'fs2-grpc-codegen', '1.1.4')
    ]
)

# 3.15 requires java 11
jooq_version = '3.14.14'
jar_library(
    name='jooq_gen',
    jars=[
        jar('org.jooq', 'jooq-codegen', jooq_version),
        jar('org.postgresql', 'postgresql', '42.2.23'),
        jar('org.flywaydb', 'flyway-commandline', '7.9.2')
    ],
    dependencies=[
        '3rdparty/datalogue/jvm/org/apache/logging/log4j'
    ]
)

SCALA_REV=2.11.12
jar_library(
  name = 'scalac-plugin-dep',
  jars = [jar(org='org.scalameta', name='semanticdb-scalac_{}'.format(SCALA_REV), rev='2.0.1')],
)
And the file is
BUILD.tools
, not
BUILD
and lives at the root of the monorepo.
h
try changing
SCALA_REV=2.11.12
to
SCALA_REV = "2.11.12"
👍 1
BUILD files are literally Python files, evaluated by a Python interpreter. So here, the error is that Python doesn't recognize
2.11.12
(without quotes) as valid syntax
f
Also, the latest version of SemanticDB here: https://mvnrepository.com/artifact/org.scalameta/semanticdb Is version
4.1.6
. Seems like using the latest version would be best.