build.gradle 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import io.spring.javaformat.gradle.tasks.CheckFormat
  2. import io.spring.javaformat.gradle.tasks.Format
  3. plugins {
  4. id "checkstyle"
  5. id "io.spring.javaformat" version "0.0.42"
  6. id 'io.spring.nohttp' version '0.0.11'
  7. }
  8. allprojects {
  9. apply plugin: 'checkstyle'
  10. apply plugin: 'io.spring.javaformat'
  11. dependencies {
  12. checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:0.0.42"
  13. }
  14. // Ensure every test task has at least a single test
  15. tasks.withType(Test).configureEach {
  16. afterSuite { desc, result ->
  17. if (result.testCount == 0) {
  18. throw new IllegalStateException("No tests were found. Ensure that useJUnitPlatform was used.")
  19. }
  20. }
  21. }
  22. // Spring Framework 6.1 requires -parameters to be able to introspect method parameter names
  23. tasks.withType(JavaCompile) {
  24. options.compilerArgs.add("-parameters")
  25. }
  26. tasks.matching { it.name == 'formatAot' }.all { task ->
  27. task.enabled = false
  28. }
  29. tasks.matching { it.name == 'formatAotTest' }.all { task ->
  30. task.enabled = false
  31. }
  32. tasks.matching { it.name == 'checkFormatAot' }.all { task ->
  33. task.enabled = false
  34. }
  35. tasks.matching { it.name == 'checkFormatAotTest' }.all { task ->
  36. task.enabled = false
  37. }
  38. tasks.matching { it.name == "checkstyleAot" }.all { task ->
  39. task.enabled = false
  40. }
  41. tasks.matching { it.name == "checkstyleAotTest" }.all { task ->
  42. task.enabled = false
  43. }
  44. }
  45. if (hasProperty('buildScan')) {
  46. buildScan {
  47. termsOfServiceUrl = 'https://gradle.com/terms-of-service'
  48. termsOfServiceAgree = 'yes'
  49. }
  50. }
  51. repositories {
  52. mavenCentral()
  53. }
  54. tasks.register('runAllTests') {
  55. var allTasks = rootProject.getAllTasks(true)
  56. var allTestsTasks = allTasks.values().collect { t ->
  57. t.findAll { it.name == 'test' || it.name == 'integrationTest' }
  58. }.flatten()
  59. it.dependsOn {
  60. allTestsTasks
  61. }
  62. }