build.gradle.kts.jinja 2.0 KB

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