build.gradle.kts.jinja 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. kotlin("jvm") version "1.8.22"
  12. kotlin("plugin.allopen") version "1.8.22"
  13. }
  14. allOpen {
  15. annotation("org.springframework.stereotype.Component")
  16. }
  17. kotlin {
  18. jvmToolchain(17)
  19. }
  20. {% if targets|selectattr('publish') -%}
  21. group = "{{ targets[0].publish_group }}"
  22. version = project.properties["version"]
  23. {% endif -%}
  24. repositories {
  25. mavenCentral()
  26. }
  27. configurations {
  28. all {
  29. exclude(group = "ch.qos.logback", module = "logback-classic")
  30. exclude(group = "org.apache.logging.log4j", module = "log4j-to-slf4j")
  31. }
  32. }
  33. {% if targets|selectattr("app_main_class") -%}
  34. application {
  35. {% for target in targets|selectattr("app_main_class") -%}
  36. mainClass.set("{{ target.app_main_class }}")
  37. {% endfor -%}
  38. }
  39. {% endif -%}
  40. java {
  41. withSourcesJar()
  42. withJavadocJar()
  43. }
  44. {% if target.jar_source_set is defined -%}
  45. {% for source_set in target.jar_source_set -%}
  46. {%- set srcdir, glob = source_set.split(':') -%}
  47. sourceSets.main.java.srcDirs += '{{ srcdir }}'
  48. {% endfor -%}
  49. {% endif -%}
  50. dependencies {
  51. {% for target in targets -%}
  52. {% if target.junit5_test -%}
  53. testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
  54. api("org.apache.commons:commons-math3:3.6.1")
  55. api("com.google.guava:guava:31.0.1-jre")
  56. {% endif -%}
  57. {% for library in target.consumer -%}
  58. {% set classpath = library.classpath -%}
  59. {% if targets|selectattr("app_main_class") -%}
  60. {% if library.excludes.consumer is defined %}
  61. implementation({{ classpath }}) {
  62. {% for exclude in library.excludes.consumer -%}
  63. {% set classpath_parts = exclude.classpath.split(':') -%}
  64. exclude group: '{{ classpath_parts[0] }}', module: '{{ classpath_parts[1] }}'
  65. {% endfor -%}
  66. }
  67. {% else -%}
  68. implementation({{ classpath }})
  69. {% endif -%}
  70. {% elif target.isTest -%}
  71. testImplementation({{ classpath }})
  72. {% else -%}
  73. api({{ classpath }})
  74. {% endif -%}
  75. {% endfor -%}
  76. {% endfor -%}
  77. }
  78. {% if targets|selectattr("junit5_test") -%}
  79. tasks.named<Test>("test") {
  80. useJUnitPlatform()
  81. }
  82. {% endif -%}
  83. tasks.test {
  84. testLogging {
  85. showStandardStreams = true
  86. events("passed", "skipped", "failed")
  87. }
  88. }
  89. val testsJar by tasks.registering(Jar::class) {
  90. dependsOn(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
  91. archiveClassifier.set("tests")
  92. from(sourceSets["test"].output)
  93. }
  94. artifacts.add(configurations.create("testOutput").name, testsJar)
  95. {% include "extra-tests.gradle.kts" ignore missing %}
  96. {% if targets|selectattr('publish') -%}
  97. {% include 'publish.gradle.kts' -%}
  98. {% endif -%}