build.gradle.kts.jinja 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_classpath -%}
  38. {% if targets|selectattr("app_main_class") -%}
  39. {% if target.lib_excludes is defined and target.lib_excludes[library]|length > 0 -%}
  40. implementation({{ library }}) {
  41. {% for exclude in target.lib_excludes[library] -%}
  42. exclude group: '{{ exclude[0] }}', module: '{{ exclude[1] }}'
  43. {% endfor -%}
  44. }
  45. {% else -%}
  46. implementation({{ library }})
  47. {% endif -%}
  48. {% elif target.isTest -%}
  49. testImplementation({{ library }})
  50. {% else -%}
  51. api({{ library }})
  52. {% endif -%}
  53. {% endfor -%}
  54. {% endfor -%}
  55. }
  56. {% if targets|selectattr("junit5_test") -%}
  57. tasks.named<Test>("test") {
  58. useJUnitPlatform()
  59. }
  60. {% endif -%}
  61. tasks.test {
  62. testLogging {
  63. showStandardStreams = true
  64. events("passed", "skipped", "failed")
  65. }
  66. }
  67. {% include "extra-tests.gradle.kts" ignore missing %}
  68. {% if targets|selectattr('publish') -%}
  69. {% include 'publish.gradle.kts' -%}
  70. {% endif -%}