build.gradle.kts.jinja 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. dependencies {
  45. {% for target in targets -%}
  46. {% if target.junit5_test -%}
  47. testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
  48. api("org.apache.commons:commons-math3:3.6.1")
  49. api("com.google.guava:guava:31.0.1-jre")
  50. {% endif -%}
  51. {% for library in target.consumer_classpath -%}
  52. {% if targets|selectattr("app_main_class") -%}
  53. {% if target.lib_excludes is defined and target.lib_excludes[library]|length > 0 -%}
  54. implementation({{ library }}) {
  55. {% for exclude in target.lib_excludes[library] -%}
  56. exclude group: '{{ exclude[0] }}', module: '{{ exclude[1] }}'
  57. {% endfor -%}
  58. }
  59. {% else -%}
  60. implementation({{ library }})
  61. {% endif -%}
  62. {% elif target.isTest -%}
  63. testImplementation({{ library }})
  64. {% else -%}
  65. api({{ library }})
  66. {% endif -%}
  67. {% endfor -%}
  68. {% endfor -%}
  69. }
  70. {% if targets|selectattr("junit5_test") -%}
  71. tasks.named<Test>("test") {
  72. useJUnitPlatform()
  73. }
  74. {% endif -%}
  75. tasks.test {
  76. testLogging {
  77. showStandardStreams = true
  78. events("passed", "skipped", "failed")
  79. }
  80. }
  81. val testsJar by tasks.registering(Jar::class) {
  82. dependsOn(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
  83. archiveClassifier.set("tests")
  84. from(sourceSets["test"].output)
  85. }
  86. artifacts.add(configurations.create("testOutput").name, testsJar)
  87. {% include "extra-tests.gradle.kts" ignore missing %}
  88. {% if targets|selectattr('publish') -%}
  89. {% include 'publish.gradle.kts' -%}
  90. {% endif -%}