build.gradle.kts.jinja 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. plugins {
  2. {% if targets|selectattr("app_main_class") -%}
  3. `application`
  4. {% else -%}
  5. `java-library`
  6. {% endif -%}
  7. {% if targets|selectattr('publish') -%}
  8. `maven-publish`
  9. `signing`
  10. {% endif -%}
  11. }
  12. {% if targets|selectattr('publish') -%}
  13. group = "{{ targets[0].publish_group }}"
  14. version = project.properties["version"]
  15. {% endif -%}
  16. repositories {
  17. mavenCentral()
  18. }
  19. {% if targets|selectattr("app_main_class") -%}
  20. application {
  21. {% for target in targets|selectattr("app_main_class") -%}
  22. mainClass.set("{{ target.app_main_class }}")
  23. {% endfor -%}
  24. }
  25. {% endif -%}
  26. java {
  27. withSourcesJar()
  28. withJavadocJar()
  29. }
  30. dependencies {
  31. {% for target in targets -%}
  32. {% if target.junit5_test -%}
  33. testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
  34. api("org.apache.commons:commons-math3:3.6.1")
  35. api("com.google.guava:guava:31.0.1-jre")
  36. {% endif -%}
  37. {% for library in target.consumer -%}
  38. {% set classpath = library.classpath -%}
  39. {% if targets|selectattr("app_main_class") -%}
  40. {% if library.excludes.consumer is defined %}
  41. implementation({{ classpath }}) {
  42. {% for exclude in library.excludes.consumer -%}
  43. {% set classpath_parts = exclude.classpath.split(':') -%}
  44. exclude group: '{{ classpath_parts[0] }}', module: '{{ classpath_parts[1] }}'
  45. {% endfor -%}
  46. }
  47. {% else -%}
  48. implementation({{ classpath }})
  49. {% endif -%}
  50. {% elif target.isTest -%}
  51. testImplementation({{ classpath }})
  52. {% else -%}
  53. api({{ classpath }})
  54. {% endif -%}
  55. {% endfor -%}
  56. {% endfor -%}
  57. }
  58. {% if targets|selectattr("junit5_test") -%}
  59. tasks.named<Test>("test") {
  60. useJUnitPlatform()
  61. }
  62. {% endif -%}
  63. tasks.test {
  64. testLogging {
  65. showStandardStreams = true
  66. events("passed", "skipped", "failed")
  67. }
  68. }
  69. {% include "extra-tests.gradle.kts" ignore missing %}
  70. {% if targets|selectattr('publish') -%}
  71. {% include 'publish.gradle.kts' -%}
  72. {% endif -%}