Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    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?