Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --experimental_allow_proto3_optional option #415

Closed
2is10 opened this issue Jun 24, 2020 · 7 comments
Closed

Support --experimental_allow_proto3_optional option #415

2is10 opened this issue Jun 24, 2020 · 7 comments

Comments

@2is10
Copy link

2is10 commented Jun 24, 2020

Since protoc version 3.12.0, this option enables the use of optional in proto3 for explicit field presence.

https://github.com/protocolbuffers/protobuf/blob/master/docs/field_presence.md

When I try to use this option, it’s unrecognized in IntelliJ, and the optional keyword is still forbidden.

image

image

@2is10
Copy link
Author

2is10 commented Jun 24, 2020

I looked for a way to configure protoc gradle tasks with --experimental_allow_proto3_optional, but GenerateProtoTask.groovy doesn’t seem to support it.

@okorz001
Copy link

okorz001 commented Jun 25, 2020

I think I have a PR that adds this but I confess I cannot get tests working (even on master)

edit: tests are passing in CI

@ejona86
Copy link
Collaborator

ejona86 commented Jun 26, 2020

The experimental flag is intended to allow time for plugin implementors to support optional. We explicitly want to discourage users going off and adding the flag. Implementors generally can run protoc manually without too much heart-ache, or they can use the test_proto3_optional file name approach. The flag will become default-enabled soon enough.

In general, passing flags to protoc yields ecosystem issues, as everyone really needs to agree on one set of options. For example, that was one of the issues with javanano. We understand you're excited about optional fields in proto, but they are still not supported at this time.

@ejona86 ejona86 closed this as completed Jun 26, 2020
@doctorpangloss
Copy link

Please reconsider, this is such a valuable feature, I promise I'll be responsible and move to whatever new syntax you want when it's officially supported.

@tobq
Copy link

tobq commented Jan 16, 2021

+1

@hkoosha
Copy link

hkoosha commented Feb 12, 2021

As now this is impossible to build google ads protos with gradle and this plugin :|
I used this workaround.

protobuf {
    def versionOverride = '3.12.0'

    Map<String, String> notation = [
            group     : 'com.google.protobuf',
            name      : 'protoc',
            version   : versionOverride,
            classifier: project.osdetector.classifier,
            ext       : 'exe',
    ]
    Dependency dep = project.dependencies.add('protobuf', notation)
    File protocFile = configurations['protobuf'].fileCollection(dep).singleFile
    if (!protocFile.canExecute() && !protocFile.setExecutable(true))
        throw new GradleException("Cannot set ${protocFile} as executable")
    println "Using protoc: ${protocFile}"

    def myProtoc = new File("$projectDir/my-protoc.sh");
    myProtoc.delete();
    if(myProtoc.exists())
        throw new GradleException("Cannot set delete ${myProtoc}")
    myProtoc << "#!/bin/bash\n"
    myProtoc << "$protocFile " + '--experimental_allow_proto3_optional $@'
    myProtoc << "\n"
    if(!myProtoc.setExecutable(true))
        throw new GradleException("Cannot set ${myProtoc} as executable")

    protoc {
        path = "${protocFile}"
    }
}

Just add "$projectDir/my-protoc.sh" to your .gitignore and you have a self-contained solution.

@ejona86
Copy link
Collaborator

ejona86 commented Feb 18, 2021

It is no longer experimental. https://github.com/protocolbuffers/protobuf/releases/tag/v3.15.0

nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
--experimental_allow_proto3_optional requires protbuf 3.15 or later

google/protobuf-gradle-plugin#415 (comment)

Also need newer binutils.
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
--experimental_allow_proto3_optional requires protbuf 3.15 or later

google/protobuf-gradle-plugin#415 (comment)

Also explicitly include gcc - rust may be installing an older version which
doesn't like the new `.relr.dyn` section
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
Note: `--experimental_allow_proto3_optional` requires protbuf 3.15 or later

google/protobuf-gradle-plugin#415 (comment)
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
Note: `--experimental_allow_proto3_optional` requires protbuf 3.15 or later

google/protobuf-gradle-plugin#415 (comment)
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
Note: `--experimental_allow_proto3_optional` requires protbuf 3.15 or later

google/protobuf-gradle-plugin#415 (comment)
nyetwurk added a commit to Blockdaemon/solana-accountsdb-plugin-kafka that referenced this issue Sep 11, 2023
Note: `--experimental_allow_proto3_optional` requires protobuf 3.15 or later

google/protobuf-gradle-plugin#415 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants