marcoferrer / kroto-plus

gRPC Kotlin Coroutines, Protobuf DSL, Scripting for Protoc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DSL Markers in maven plugin?

asad-awadia opened this issue · comments

How do you use use_dsl_markers in ProtoBuildersGenOptions via maven?

Which protoc plugin artifact are your using? protoc-gen-grpc-coroutines or protoc-gen-kroto-plus? Only the kroto-plus artifact with support the use_dsl_markers option. To enable it, confirm your kroto config path is being set correctly in maven.

<execution>
        <id>kroto-plus</id>
        <goals>
             <goal>compile-custom</goal>
         </goals>
         <configuration>
             <pluginId>kroto-plus</pluginId>
             <pluginArtifact>com.github.marcoferrer.krotoplus:protoc-gen-kroto-plus:${krotoPlusVersion}:jar:jvm8</pluginArtifact>
             <pluginParameter>ConfigPath=${project.basedir}/krotoPlusConfig.asciipb</pluginParameter>
         </configuration>
</execution>

Then in krotoPlusConfig.asciipb, inside your proto_builders configuration, set the flag.
asciipb

proto_builders {
    ....
    use_dsl_markers: true
}

json

"protoBuilders": [
     {
         .....,
         "useDslMarkers": true
     }
]

Another important note is that the use_dsl_markers option relies on the protoc-insertions feature.
So the output directory of both protoc-gen-kroto-plus and protoc-gen-java must match.

Im not 100% familiar with all the configuration options for the protobuf maven plugin, but a quick google search shows the outputDirectory option might be what you need

<configuration>
    <pluginId>kroto-plus</pluginId>
    <pluginArtifact>com.github.marcoferrer.krotoplus:protoc-gen-kroto-plus:${krotoPlusVersion}:jar:jvm8</pluginArtifact>
    <pluginParameter>ConfigPath=${project.basedir}/krotoPlusConfig.asciipb</pluginParameter>
    <outputDirectory>${basedir}/target/generated-sources/path/to/java/output</outputDirectory>
</configuration>

I had some time to fully dig into this and found the source of the issue. The protobuf maven plugin doesnt fully support the protoc insertions api at the moment. My findings are documented here

Closing as a duplicate of #28