proto_prepare.jinja 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {#- empty string #}
  2. {%- if target.proto_files|length %}
  3. val prepareMainProtos = tasks.register<Copy>("prepareMainProtos") {
  4. from("$project_root") {
  5. {#- list of all current project proto files -#}
  6. {%- for proto in target.proto_files %}
  7. include("{{ proto }}")
  8. {%- endfor %}
  9. }
  10. into(mainProtosDir)
  11. }
  12. {%- endif %}
  13. {% if libraries|length -%}
  14. val extractMainLibrariesProtos = tasks.register<Copy>("extractMainLibrariesProtos") {
  15. from("$project_root") {
  16. {#- list of all library directories -#}
  17. {%- for library in libraries -%}
  18. {%- set path_and_jar = rsplit(library.jar, '/', 2) %}
  19. include("{{ path_and_jar[0] }}/**/*.proto")
  20. {%- endfor %}
  21. }
  22. into(mainExtractedIncludeProtosDir)
  23. }
  24. {% endif -%}
  25. afterEvaluate {
  26. {%- if target.proto_files|length %}
  27. tasks.getByName("extractProto").dependsOn(prepareMainProtos)
  28. {%- endif %}
  29. {%- if libraries|length %}
  30. tasks.getByName("extractProto").dependsOn(extractMainLibrariesProtos)
  31. {%- endif %}
  32. }
  33. tasks.getByName("sourcesJar").dependsOn("generateProto")
  34. {%- if with_kotlin %}
  35. tasks.getByName("compileKotlin").dependsOn("generateProto")
  36. {%- endif %}