build.gradle 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.withType(Format).tap {
  27. configureEach {
  28. it.enabled = !it.identityPath.toString().contains("saml2")
  29. }
  30. }
  31. tasks.withType(CheckFormat).tap {
  32. configureEach {
  33. it.enabled = !it.identityPath.toString().contains("saml2")
  34. }
  35. }
  36. tasks.matching { it.name == 'formatAot' }.all { task ->
  37. task.enabled = false
  38. }
  39. tasks.matching { it.name == 'formatAotTest' }.all { task ->
  40. task.enabled = false
  41. }
  42. tasks.matching { it.name == 'checkFormatAot' }.all { task ->
  43. task.enabled = false
  44. }
  45. tasks.matching { it.name == 'checkFormatAotTest' }.all { task ->
  46. task.enabled = false
  47. }
  48. tasks.matching { it.name == "checkstyleAot" }.all { task ->
  49. task.enabled = false
  50. }
  51. tasks.matching { it.name == "checkstyleAotTest" }.all { task ->
  52. task.enabled = false
  53. }
  54. }
  55. if (hasProperty('buildScan')) {
  56. buildScan {
  57. termsOfServiceUrl = 'https://gradle.com/terms-of-service'
  58. termsOfServiceAgree = 'yes'
  59. }
  60. }
  61. repositories {
  62. mavenCentral()
  63. }
  64. tasks.register('runAllTests') {
  65. var allTasks = rootProject.getAllTasks(true)
  66. var allTestsTasks = allTasks.values().collect { t ->
  67. t.findAll { it.name == 'test' || it.name == 'integrationTest' }
  68. }.flatten()
  69. it.dependsOn {
  70. allTestsTasks
  71. }
  72. }