build.gradle.kts.jinja 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 classpath|replace('"','') == classpath -%}
  40. {% set classpath = '"' + classpath + '"' -%}
  41. {% endif -%}
  42. {% if mainClass -%}
  43. {% if library.excludes.consumer is defined %}
  44. implementation({{ classpath }}) {
  45. {% for exclude in library.excludes.consumer if exclude.classpath -%}
  46. {% set classpath = exclude.classpath|replace('"','') -%}
  47. {% set classpath_parts = split(classpath, ':') -%}
  48. exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
  49. {% endfor -%}
  50. }
  51. {% else -%}
  52. implementation({{ classpath }})
  53. {% endif -%}
  54. {% else -%}
  55. api({{ classpath }})
  56. {% endif -%}
  57. {% endfor -%}
  58. {% for extra_target in extra_targets -%}
  59. {% for library in extra_target.consumer -%}
  60. {% set classpath = library.classpath -%}
  61. {% if classpath|replace('"','') == classpath -%}
  62. {% set classpath = '"' + classpath + '"' -%}
  63. {% endif -%}
  64. testImplementation({{ classpath }})
  65. {% endfor -%}
  66. {% endfor -%}
  67. }
  68. {% if hasJunit5Test -%}
  69. tasks.named<Test>("test") {
  70. useJUnitPlatform()
  71. }
  72. {% endif -%}
  73. tasks.test {
  74. testLogging {
  75. showStandardStreams = true
  76. events("passed", "skipped", "failed")
  77. }
  78. }
  79. {% include "extra-tests.gradle.kts" ignore missing %}
  80. {% if publish -%}
  81. {% include 'publish.gradle.kts' -%}
  82. {% endif -%}