rejoiner descriptor问题

今日份Rejoiner,今天老大让我弄了个东西,就是在proto文件生成的同时添加一个注释,这个注释可以给前台人员看到,因为rejoiner的文章比较少,所以弄了一上午时间,难受啊,
然后在这里说一下解决过程。

首先说一下解决后的感悟吧,这个东西的执行是这样的:首先在自动生成的时候,直接将proto文件中的注释都添加在一个文件中,然后Regoiner将这些注释在注入进去,这里是自动注入的,所以不用担心,

解决步骤:
1.首先要添加一个生成description文件的依赖
可以用

        all().each { task ->
            task.plugins {
                grpc {
                    // To generate deprecated interfaces and static bindService method,
                    // turn the enable_deprecated option to true below:
                    option 'enable_deprecated=false'
                }
            }
            // If true, will generate a descriptor_set.desc file under
            // $generatedFilesBaseDir/$sourceSet. Default is false.
            // See --descriptor_set_out in protoc documentation about what it is.
            task.generateDescriptorSet = true

            // Allows to override the default for the descriptor set location
            task.descriptorSetOptions.path =
                    "${projectDir}/build/descriptors/${task.sourceSet.name}.dsc"

            // If true, the descriptor set will contain line number information
            // and comments. Default is false.
            task.descriptorSetOptions.includeSourceInfo = true

            // If true, the descriptor set will contain all transitive imports and
            // is therefore self-contained. Default is false.
//            task.descriptorSetOptions.includeImports = true
        }

也可以使用

        ofSourceSet('main').each{task ->
            task.generateDescriptorSet = true
            task.descriptorSetOptions.includeImports = true
            task.descriptorSetOptions.includeSourceInfo = true
            task.descriptorSetOptions.path = "${buildDir}/resources/main/META-INF/proto/descriptor_set.desc"
            task.plugins {
                grpc {}
            }
        }

然后生成文件后就会产生一个descriptor_set.desc的文件,这个文件中包含所有的注释,然后Rejoiner就会将它自动注入,这样方便前台人员,传参数,写代码,有了注释,方便快捷很多。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值