Open crazyk2 opened 5 years ago
I spent some time digging into this. You're 100% correct about the lack of --java_out
. It looks like omitting it causes issues with the protoc insertions api.
It also looks like the protobuf maven plugin invokes protoc once for each plugin defined. The --java_out
arg is not added when configuring custom native
plugins (as seen here) but is added when using java plugins (as seen here).
I tried using the java plugin configuration since it seems to be the only available option for including java out arg.
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<extensions>true</extensions>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier}</protocArtifact>
<outputDirectory>${basedir}/target/generated-sources/protobuf/java</outputDirectory>
<clearOutputDirectory>false</clearOutputDirectory>
<protocPlugins>
<plugin>
<id>kroto-plus</id>
<groupId>com.github.marcoferrer.krotoplus</groupId>
<artifactId>protoc-gen-kroto-plus</artifactId>
<version>${krotoplus.version}</version>
<classifier>jvm8</classifier>
<mainClass>org.springframework.boot.loader.JarLauncher</mainClass>
</plugin>
</protocPlugins>
</configuration>
<executions>
...
</executions>
</plugin>
I checked out the output from this configuration and it does indeed properly pass the java out arg BUT now theres a new issue. The protobuf maven plugin doesnt allow you to pass any pluginParameter
arguments when using this style of configuration.
I tried every supported configuration with no success. This looks like a bug in the maven plugin.
It doesnt support the insertions api using custom native plugins. The insertions api should work in theory if you use a java plugin but doesn't support passing pluginParameter
arguments.
Still doesn't work... Not really usable with maven :(
I use maven and faced with a problem when had used your plugin. Short log of problem is
[ERROR] PROTOC FAILED: some/path//SomeClass.java: Tried to insert into file that doesn't exist.
My pom.xmlas noticed there, there and there
Then I tried protobuf-gradle-plugin with settings
and that worked. I ran command in debug mode and compare output protobuf-maven-plugin and protobuf-gradle-plugin. protobuf-gradle-plugin run only one protoc command with pipe of plugins
--java_out --> --protoc-gen-grpc --> protoc-gen-kroto protobuf-maven-plugin run protoc commands N executions times and in my case last command is
that lead to build failure. When I have added
--java_out=/api/target/generated-sources/protobuf/java
to command above. It worked fineI don't know which products this bug\behavior belongs to.