Git Product home page Git Product logo

Comments (10)

thesamet avatar thesamet commented on June 15, 2024

I think that ScalaPB should work with recent versions of protobuf-java (such as 3.22.x). Can you share more information about your project? Are you generating Scala and Java code? Are you setting PB.protocVersion to 3.22.5? What code path leads to the exception you are seeing? Can you share a minimal project that reproduces this problem?

from scalapb.

kusaeva avatar kusaeva commented on June 15, 2024

Oh so this is just my misunderstanding. I thought I just will not work.
Yes, I have java + scala repo and generating both scala / java classes from proto. So it is safe to use protoc + protobuf-java with version (3.22.5) > currently hardcoded in ScalaPB (3.19.6), is it?

from scalapb.

thesamet avatar thesamet commented on June 15, 2024

I haven't tested this specific configuration, so it may or may not work. However, generally it should be ok to use a newer protobuf-java and protoc than the one used with ScalaPB. Please test that and report here you see any issues.

from scalapb.

kusaeva avatar kusaeva commented on June 15, 2024

It looks like protobuf v3.22.0 introduces incompatible change in DescriptorProtos.FieldOptions.Builder setExtension method: now it is inherited from com.google.protobuf.GeneratedMessageV3.ExtendableBuilder
In 3.19.6 it was presented in DescriptorProtos.FieldOptions.Builder itself

I tried to compile scala proto librarary with current scalapb and protobuf-java + protoc 3.22.5 and get such error:
--scala_out: java.lang.NoSuchMethodError: 'com.google.protobuf.DescriptorProtos$FieldOptions$Builder com.google.protobuf.DescriptorProtos$FieldOptions$Builder.setExtension(com.google.protobuf.GeneratedMessage$GeneratedExtension, java.lang.Object)' at scalapb.compiler.ProtobufGenerator.updateField$1(ProtobufGenerator.scala:1471)

Then I upgrade protobuf (and protoc) in scalapb repo to 3.22.5 and just recompiled compilerplugin. It fixes the problem.

Would you mind to upgrade protobuf to 3.22.5?

from scalapb.

thesamet avatar thesamet commented on June 15, 2024

@kusaeva can you provide a minimal project that demonstrates the problem? I prefer to refrain from a releasing a 0.12.0 if not necessary.

from scalapb.

kusaeva avatar kusaeva commented on June 15, 2024

sure, here it is https://github.com/kusaeva/scalapb-protobuf-22.5
Running sbt compile fails with protobuf 3.22.5 but works with 3.21.7

from scalapb.

thesamet avatar thesamet commented on June 15, 2024

Thanks for sending this. It looks like the use of dependencyOverrides affects the protobuf version used at compile time (!) and I wonder if this is an sbt bug. If you change dependencyOverrides to libraryDependencies then it works. Is there a reason for the usage of dependencyOverrides?

from scalapb.

kusaeva avatar kusaeva commented on June 15, 2024

I used dependencyOverrides just for example. My real project built with bazel, where I have to use certain protobuf version (22.5). And I get the same error

from scalapb.

thesamet avatar thesamet commented on June 15, 2024

Got it. I am planning of making a release with a more recent version of protobuf. However, since the problem occurs at compile time, it looks like the generator isn't running in isolation as I thought (we have a custom class loader that was meant to provide that). So upgrading can cause binary incompatibility for users who need the older version at compile time. While we do the new release, care to share a bazel reproduction of the issue? I am not sure how the class loading for the generator works there.

from scalapb.

kusaeva avatar kusaeva commented on June 15, 2024

Sorry for late reply, I've added bazel build to the same repro repository: https://github.com/kusaeva/scalapb-protobuf-22.5
To see the error run: bazel build //:all

from scalapb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.