run_java_program.jinja 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. {%- if target.runs|length -%}
  2. {%- for run in target.runs %}
  3. val runJav{{ loop.index }} = task<JavaExec>("runJavaProgram{{ loop.index }}") {
  4. group = "build"
  5. description = "Code generation by run java program"
  6. {%- set classpaths = run.classpath|reject('eq', '@.cplst') -%}
  7. {%- if classpaths|length -%}
  8. {% for classpath in classpaths -%}
  9. {%- set rel_file_classpath = classpath|replace('@', '')|replace(export_root, '')|replace(arcadia_root, '') %}
  10. val classpaths = "$project_root/" + File("$project_root{{ rel_file_classpath }}").readText().trim().replace(":", ":$project_root/")
  11. classpath = files(classpaths.split(":"))
  12. {%- endfor -%}
  13. {%- endif %}
  14. mainClass.set("{{ run.args[0] }}")
  15. {%- if run.args|length > 1 %}
  16. args = listOf(
  17. {%- for arg in run.args -%}
  18. {%- if not loop.first %}
  19. "{{ arg }}",
  20. {%- endif -%}
  21. {%- endfor %}
  22. )
  23. {% endif -%}
  24. {%- if run.in_dir -%}
  25. {%- for in_dir in run.in_dir %}
  26. inputs.files(fileTree("{{ in_dir }}"))
  27. {% endfor -%}
  28. {%- endif -%}
  29. {%- if run.in -%}
  30. {%- for in_file in run.in %}
  31. inputs.files("{{ in_file }}")
  32. {% endfor -%}
  33. {%- endif -%}
  34. {%- if run.out_dir|length -%}
  35. {%- for out_dir in run.out_dir|unique %}
  36. outputs.dir("{{ out_dir }}")
  37. {%- endfor -%}
  38. {%- endif -%}
  39. {#-
  40. Не использованы аттрибуты
  41. run-out="list"
  42. run-cwd="str"
  43. run-in_dirs_inputs="list"
  44. run-in_noparse="list"
  45. run-tool="list"
  46. #}
  47. }
  48. tasks.getByName("sourcesJar").dependsOn(runJav{{ loop.index }})
  49. tasks.compileJava.configure {
  50. dependsOn(runJav{{ loop.index }})
  51. }
  52. {%- if with_kotlin %}
  53. tasks.compileKotlin.configure {
  54. dependsOn(runJav{{ loop.index }})
  55. }
  56. {%- endif %}
  57. {% endfor -%}
  58. {% endif -%}