Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Sergei Ivanov
    @sergei-ivanov
    There must be two plugin invocations in your lifecycle which are both configured to generate a descriptor set. That is my guess, but I’d need to see your POM and maven command line to confirm.
    I’ll fix the attach flag in the next release. At the moment my main project is going through its death march phase, and because of that I cannot dedicate enough resources to the plugin. But I promise I’ll fix it as soon as I have time.
    Franz van Betteraey
    @FrVaBe
    @Sahasrara I had the same issue as you and use two separate executions now, one with writeDescriptorSet=trueand the other with writeDescriptorSet=false; as for example like this:
    <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <!-- common configuration for all executions -->
        <configuration>
            <clearOutputDirectory>false</clearOutputDirectory>
            <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
        </configuration>
        <executions>
            <!-- execution to compile the proto files without grpc plugin; also attach '*.proto' files
                and generate DescriptorSet file ('*.protobin') (must be done only once because otherwise it will
                be attached twice to the build and the double 'deploy' of the same protobin artifact fails) -->
            <execution>
                <id>protobuf-compile</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>compile</goal>
                </goals>
                <configuration>
                    <attachProtoSources>true</attachProtoSources>
                    <writeDescriptorSet>true</writeDescriptorSet>
                    <includeSourceInfoInDescriptorSet>true</includeSourceInfoInDescriptorSet>
                    <includeDependenciesInDescriptorSet>true</includeDependenciesInDescriptorSet>
                    <attachDescriptorSet>true</attachDescriptorSet>
                    <descriptorSetClassifier>descriptorSet</descriptorSetClassifier>
                </configuration>
            </execution>
            <!-- execution to compile the proto files with the grpc plugin -->
            <execution>
                <id>protobuf-compile-custom</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>compile-custom</goal>
                </goals>
                <configuration>
                    <attachProtoSources>false</attachProtoSources>
                    <writeDescriptorSet>false</writeDescriptorSet>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
            </execution>
        </executions>
    </plugin>
    Sergei Ivanov
    @sergei-ivanov
    I have fixed it on master as well
    Nadav Samet
    @thesamet
    Hey friends, I am the author of a library called ScalaPB (protobuf code generator for Scala). I want to provide an example project that shows how to use ScalaPB as a Java-based generator through protobuf-maven-plugin. I was able to do that, but I am looking for a way to inhibit Java code generation - so only the ScalaPB plugin gets invoked (in other words, I don't want --java_out to be passed to protoc). How do I go about that?
    Nadav Samet
    @thesamet
    Also, how do I pass parameters to the plugin, so it becomes --scalapb_out=param1,param2:... ?
    Sergei Ivanov
    @sergei-ivanov
    Hi, is your code generator java-based or native?
    Nadav Samet
    @thesamet
    It is java based
    Sergei Ivanov
    @sergei-ivanov
    ok, I think the current functionality for java-based plugins is tied to compile-java goal
    Sergei Ivanov
    @sergei-ivanov
    I think your issue vaguely relates to this one: xolstice/protobuf-maven-plugin#56
    I'll try to address that at some point
    bfmyr4
    @bfmyr4
    For csharp, the root namespace can be specified by "--csharp_opt=base_namespace=" on the protoc command line. Is there a way to specify that in pom? Otherwise csharp in generated-sources is flat and has no directory structure.
    Sergei Ivanov
    @sergei-ivanov
    @bfmyr4 I think your case will be covered by xolstice/protobuf-maven-plugin#56
    Looks like the additional parameter syntax has been adopted by almost all bundled protoc compiler plugins
    bfmyr4
    @bfmyr4
    I must be missing something. I just want to use the built in compile-csharp goal. Something like this doesn't seem to work. Example:
    <plugin>
    <groupId>org.xolstice.maven.plugins</groupId>
    <artifactId>protobuf-maven-plugin</artifactId>
    <version>0.6.1</version>
    <executions>
    <execution>
    <id>java</id>
    <goals>
    <goal>compile</goal>
    <goal>test-compile</goal>
    </goals>
    </execution>
    <execution>
    <id>csharp</id>
    <goals>
    <goal>compile-csharp</goal>
    </goals>
    <configuration>
    <pluginParameter>--csharp_opt=base_namespace=Com</pluginParameter>
    <protocArtifact>com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}</protocArtifact>
    <attachProtoSources>false</attachProtoSources>
    <useArgumentFile>true</useArgumentFile>
    </configuration>
    </execution>
    </executions>
    <configuration>
    <protocArtifact>com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}</protocArtifact>
    <attachProtoSources>false</attachProtoSources>
    <useArgumentFile>true</useArgumentFile>
    </configuration>
    </plugin>
    Sergei Ivanov
    @sergei-ivanov
    can you please create a separate ticket for that, I'll take a look when I have a chance
    bfmyr4
    @bfmyr4
    ok
    Mikhail Ivanov
    @Lander

    Hello All, I've created a custom plugin using Java. I'm using Win10 for development. When I'm trying to execute an compile-custom goal, I can see that protoc-gen-ts.exe is located under target/protoc-plugins (alongside with protoc executable). Although, protoc unable to locate plugin executable. Here is my configuration

                <plugin>
                    <groupId>org.xolstice.maven.plugins</groupId>
                    <artifactId>protobuf-maven-plugin</artifactId>
                    <version>0.6.1</version>
                    <extensions>true</extensions>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile-custom</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <pluginId>ts</pluginId>
                        <protocPlugins>
                            <protocPlugin>
                                <id>ts</id>
                                <groupId>com.protobuf</groupId>
                                <artifactId>protoc-gen-ts</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <mainClass>com.protobuf.ts.ProtocGenTs</mainClass>
                            </protocPlugin>
                        </protocPlugins>
                        <protocArtifact>com.google.protobuf:protoc:3.9.0:exe:${os.detected.classifier}</protocArtifact>
                        <protoSourceRoot>${project.parent.basedir}\src\main</protoSourceRoot>
                    </configuration>
                </plugin>

    Is there something I'm missing?

    Output: [ERROR] PROTOC FAILED: 'protoc-gen-ts' is not recognized as an internal or external command, operable program or batch file.
    Sergei Ivanov
    @sergei-ivanov
    Hi @Lander can you run maven with -X and post any relevant debug output preceding the error?
    Sergei Ivanov
    @sergei-ivanov
    actually, no need for that, it is much simpler.
    remove <pluginId>ts</pluginId>
    and replace compile-custom with compile
    should be enough to make it work
    Mikhail Ivanov
    @Lander
    Hey Sergei! It would compile java files which I don't need
    My plugin creates TypeScript .d.ts.files based on protobuf messages. TypeScript file are only used by Front-end, thus I don't need extra java files to be generated
    Sergei Ivanov
    @sergei-ivanov
    At the moment it is not possible (historically we used custom java plugins to generate java sources). Vote for #62
    Mikhail Ivanov
    @Lander
    Got it! Will do! Thanks!
    Slava96
    @Slava96
    Hello!
    I have a question!
    I'm using Intellij Idea and try to compile single proto file with service and 2 messages.
    Why plugin generate message files into java, but service file into grpc-java.
    Because of it - Intellij cannot find this class for import
    Sergei Ivanov
    @sergei-ivanov
    @Slava96 Can you share your configuration? IDEA should correctly pick up and resolve all source directories, as long as protobuf-maven-plugin is configured as part of Maven lifecycle.
    Slava96
    @Slava96
    <plugin>
    <groupId>org.xolstice.maven.plugins</groupId>
    <artifactId>protobuf-maven-plugin</artifactId>
    <version>0.6.1</version>
    <configuration>
    <protocArtifact>
    com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}
    </protocArtifact>
    <pluginId>grpc-java</pluginId>
    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.23.0:exe:${os.detected.classifier}</pluginArtifact>
    </configuration>
    <executions>
    <execution>
    <goals>
    <goal>compile</goal>
    <goal>compile-custom</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <extensions>
    <extension>
    <groupId>kr.motd.maven</groupId>
    <artifactId>os-maven-plugin</artifactId>
    </extension>
    </extensions>
    image.png
    It's result

    syntax = "proto3";

    option java_multiple_files = true;
    option java_package = "com.example.demo.grpc.server.proto";
    option java_outer_classname = "DemoProto";

    service Check {
    rpc FindMe (Request) returns (Response) {
    }
    }

    message Request {
    string content = 1;
    }

    message Response {
    string content = 1;
    }

    It's proto file
    Slava96
    @Slava96
    What's the default proto-path value on plugin?
    Sergei Ivanov
    @sergei-ivanov
    Hi, sorry for the delay. The configuration above looks perfectly valid, and in your screenshot IDEA has correctly detected the generated-sources/protobuf/grpc-java as a source path. Or did you have to mark it as a source folder manually?
    Can you create a small project on GitHub to demonstrate the problem?