build.gradle.kts.jinja 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_classpath -%}
  58. {% if targets|selectattr("app_main_class") -%}
  59. {% if target.lib_excludes is defined and target.lib_excludes[library]|length > 0 -%}
  60. implementation({{ library }}) {
  61. {% for exclude in target.lib_excludes[library] -%}
  62. exclude group: '{{ exclude[0] }}', module: '{{ exclude[1] }}'
  63. {% endfor -%}
  64. }
  65. {% else -%}
  66. implementation({{ library }})
  67. {% endif -%}
  68. {% elif target.isTest -%}
  69. testImplementation({{ library }})
  70. {% else -%}
  71. api({{ library }})
  72. {% endif -%}
  73. {% endfor -%}
  74. {% endfor -%}
  75. }
  76. {% if targets|selectattr("junit5_test") -%}
  77. tasks.named<Test>("test") {
  78. useJUnitPlatform()
  79. }
  80. {% endif -%}
  81. tasks.test {
  82. testLogging {
  83. showStandardStreams = true
  84. events("passed", "skipped", "failed")
  85. }
  86. }
  87. val testsJar by tasks.registering(Jar::class) {
  88. dependsOn(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
  89. archiveClassifier.set("tests")
  90. from(sourceSets["test"].output)
  91. }
  92. artifacts.add(configurations.create("testOutput").name, testsJar)
  93. {% include "extra-tests.gradle.kts" ignore missing %}
  94. {% if targets|selectattr('publish') -%}
  95. {% include 'publish.gradle.kts' -%}
  96. {% endif -%}