1

I'm using the gradle plugin 'com.google.protobuf:protoc:3.6.0' for generating my .java files from .proto files.

Additionally I want to generate documentation for my .proto files. For this I found protoc-gen-doc.exe. This works fine fomr the commandline with the following command:

path/to/protoc/protoc --plugin=protoc-gen-doc=path/to/docGen/protoc-gen-doc.exe --doc_out=./doc --doc_opt=html,index.html test.proto

In my gradle script I have the following task:

protobuf {
    generatedFilesBaseDir = "$projectDir/src/"
    protoc {
        artifact = 'com.google.protobuf:protoc:3.6.0'
    }
    plugins {
        doc {
          path = 'path/to/genDoc/protoc-gen-doc.exe'
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                doc {}
            }
        }
    }
}

How I can pass the --doc_out and --doc_opt parameters to the plugin?

Jürgen
  • 146
  • 12

1 Answers1

1

According to the documentation the following should work:

protobuf {
  ...
  generateProtoTasks {
    all().each { task ->
      task.plugins {
        doc {
          outputSubDir = 'doc'
          option 'html'
          option 'index.html'
        }
      }
    }
  }            
Hiery Nomus
  • 17,429
  • 2
  • 41
  • 37