sbt / sbt-avro

sbt plugin for compiling Avro schemas, similar to sbt-protobuf
Other
33 stars 17 forks source link

Not working with the `1.12.0` `avro` package #192

Closed rganatra-kasada closed 1 month ago

rganatra-kasada commented 2 months ago

Hello! :wave:

I'm unable to generate Java code for avro schemas since upgrading the org.apache.avro.avro package to the latest 1.12.0 (which was recently published), which works just fine with 1.11.3. Basically running sbt avroGenerate (or even opening up the sbt shell in the project for that matter) fails with:

$  sbt
[info] welcome to sbt 1.10.1 (Eclipse Adoptium Java 17)
[info] loading global plugins from /home/rudrenganatra/.sbt/1.0/plugins
[info] loading settings for project schemas-build from plugins.sbt ...
[info] loading project definition from /home/rudrenganatra/Desktop/test-avro-project/schemas/project
[info] Updating schemas-build
https://repo1.maven.org/maven2/org/apache/avro/avro-compiler/1.12.0/avro-compiler-1.12.0.pom
  100.0% [##########] 9.0 KiB (6.6 KiB / s)
https://repo1.maven.org/maven2/org/apache/avro/avro-parent/1.12.0/avro-parent-1.12.0.pom
  100.0% [##########] 24.5 KiB (81.8 KiB / s)
https://repo1.maven.org/maven2/org/apache/avro/avro-toplevel/1.12.0/avro-toplevel-1.12.0.pom
  100.0% [##########] 26.7 KiB (73.8 KiB / s)
https://repo1.maven.org/maven2/org/apache/avro/avro/1.12.0/avro-1.12.0.pom
  100.0% [##########] 8.1 KiB (20.7 KiB / s)
https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.26.2/commons-compress-1.26.2.pom
  100.0% [##########] 22.4 KiB (73.7 KiB / s)
https://repo1.maven.org/maven2/commons-codec/commons-codec/1.17.0/commons-codec-1.17.0.pom
  100.0% [##########] 17.5 KiB (76.5 KiB / s)
[info] Resolved schemas-build dependencies
[info] Fetching artifacts of schemas-build
https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.26.2/commons-compress-1.26.2.jar
  100.0% [##########] 1.0 MiB (1.2 MiB / s)
https://repo1.maven.org/maven2/org/apache/avro/avro-compiler/1.12.0/avro-compiler-1.12.0.jar
  100.0% [##########] 113.6 KiB (122.3 KiB / s)
https://repo1.maven.org/maven2/commons-codec/commons-codec/1.17.0/commons-codec-1.17.0.jar
  100.0% [##########] 363.9 KiB (320.9 KiB / s)
https://repo1.maven.org/maven2/org/apache/avro/avro/1.12.0/avro-1.12.0.jar
  100.0% [##########] 696.7 KiB (540.5 KiB / s)
[info] Fetched artifacts of schemas-build
[info] loading settings for project root from build.sbt ...
java.lang.NoSuchMethodError: 'boolean org.apache.avro.Schema$Parser.getValidate()'
    at com.github.sbt.avro.DefaultSchemaParserBuilder$.template(DefaultSchemaParserBuilder.scala:30)
    at com.github.sbt.avro.DefaultSchemaParserBuilder$.default(DefaultSchemaParserBuilder.scala:24)
    at com.github.sbt.avro.SbtAvro$.$anonfun$globalSettings$7(SbtAvro.scala:121)
    at sbt.internal.util.Init$Value.$anonfun$apply$2(Settings.scala:922)
    at sbt.internal.util.EvaluateSettings.$anonfun$constant$1(INode.scala:212)
    at sbt.internal.util.EvaluateSettings$MixedNode.evaluate0(INode.scala:229)
    at sbt.internal.util.EvaluateSettings$INode.evaluate(INode.scala:171)
    at sbt.internal.util.EvaluateSettings.$anonfun$submitEvaluate$1(INode.scala:88)
    at sbt.internal.util.EvaluateSettings.sbt$internal$util$EvaluateSettings$$run0(INode.scala:100)
    at sbt.internal.util.EvaluateSettings$$anon$3.run(INode.scala:95)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
[error] java.lang.NoSuchMethodError: 'boolean org.apache.avro.Schema$Parser.getValidate()'
[error] Use 'last' for the full log.
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)

I think the change that broke it is this particular one in the avro project since it removes Parser.getValidate() and Parser.setValidate() methods altogether that sbt-avro relies on.

Here's a minimal project to replicate the issue: test-avro-project.zip

I'm not familiar enough with the code and avro in general to put up a fix/change myself at this point unfortunately. Is this something that could be looked at?

Thank you very much!

RustedBones commented 2 months ago

Hi! Yes I've noticed the breaking change and prepared what's needed to support the new version in https://github.com/sbt/sbt-avro/pull/190.

I'll make some time to cut a new release ASAP

rganatra-kasada commented 2 months ago

Hey @RustedBones thank you, much appreciated!

RustedBones commented 1 month ago

Just release 3.5.0