build.gradle.kts.jinja 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. implementation({{ library }})
  40. {% elif target.isTest -%}
  41. testImplementation({{ library }})
  42. {% else -%}
  43. api({{ library }})
  44. {% endif -%}
  45. {% endfor -%}
  46. {% endfor -%}
  47. }
  48. {% if targets|selectattr("junit5_test") -%}
  49. tasks.named<Test>("test") {
  50. useJUnitPlatform()
  51. }
  52. {% endif -%}
  53. {% if targets|selectattr('publish') -%}
  54. {% include 'publish.gradle.kts' -%}
  55. {% endif -%}