Change output directory of generated code in gradle

前端 未结 3 956
名媛妹妹
名媛妹妹 2021-02-19 03:32

Project contains annotation processor which generates java code during compilation. By default, gradle outputs generated source files into build/classes directory.

3条回答
  •  长情又很酷
    2021-02-19 04:12

    By default generated Java files are under $generatedFilesBaseDir/$sourceSet/$builtinPluginName, where $generatedFilesBaseDir is $buildDir/generated/source/proto by default, and is configurable. E.g.,

    protobuf {
     ...
      generatedFilesBaseDir = "$projectDir/src/generated"
    }
    

    The subdirectory name, which is by default $builtinPluginName, can also be changed by setting the outputSubDir property in the builtins or plugins block of a task configuration within generateProtoTasks block (see previous section). E.g.,

    {
      task ->
      task.plugins {
        grpc {
        // Write the generated files under
        // "$generatedFilesBaseDir/$sourceSet/grpcjava"
        outputSubDir = 'grpcjava'
        }
      }
    }
    

    to see github protobuf-gradle-plugin

提交回复
热议问题