build.gradle 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import io.spring.gradle.IncludeRepoTask
  2. import trang.RncToXsd
  3. buildscript {
  4. dependencies {
  5. classpath libs.io.spring.javaformat.spring.javaformat.gradle.plugin
  6. classpath libs.io.spring.nohttp.nohttp.gradle
  7. classpath libs.io.freefair.gradle.aspectj.plugin
  8. classpath libs.org.jetbrains.kotlin.kotlin.gradle.plugin
  9. classpath libs.com.netflix.nebula.nebula.project.plugin
  10. }
  11. repositories {
  12. maven { url 'https://plugins.gradle.org/m2/' }
  13. }
  14. }
  15. plugins {
  16. alias(libs.plugins.org.gradle.wrapper.upgrade)
  17. }
  18. apply plugin: 'io.spring.nohttp'
  19. apply plugin: 'locks'
  20. apply plugin: 's101'
  21. apply plugin: 'io.spring.convention.root'
  22. apply plugin: 'org.jetbrains.kotlin.jvm'
  23. apply plugin: 'org.springframework.security.update-dependencies'
  24. apply plugin: 'org.springframework.security.update-version'
  25. apply plugin: 'org.springframework.security.sagan'
  26. apply plugin: 'org.springframework.github.milestone'
  27. apply plugin: 'org.springframework.github.changelog'
  28. apply plugin: 'org.springframework.github.release'
  29. group = 'org.springframework.security'
  30. description = 'Spring Security'
  31. ext.snapshotBuild = version.contains("SNAPSHOT")
  32. ext.releaseBuild = version.contains("SNAPSHOT")
  33. ext.milestoneBuild = !(snapshotBuild || releaseBuild)
  34. repositories {
  35. mavenCentral()
  36. maven { url "https://repo.spring.io/milestone" }
  37. }
  38. tasks.named("saganCreateRelease") {
  39. referenceDocUrl = "https://docs.spring.io/spring-security/reference/{version}/index.html"
  40. apiDocUrl = "https://docs.spring.io/spring-security/site/docs/{version}/api/"
  41. }
  42. tasks.named("gitHubCheckMilestoneHasNoOpenIssues") {
  43. repository {
  44. owner = "spring-projects"
  45. name = "spring-security"
  46. }
  47. }
  48. tasks.named("gitHubNextReleaseMilestone") {
  49. repository {
  50. owner = "spring-projects"
  51. name = "spring-security"
  52. }
  53. }
  54. tasks.named("gitHubCheckNextVersionDueToday") {
  55. repository {
  56. owner = "spring-projects"
  57. name = "spring-security"
  58. }
  59. }
  60. tasks.named("scheduleNextRelease") {
  61. repository {
  62. owner = "spring-projects"
  63. name = "spring-security"
  64. }
  65. weekOfMonth = 3
  66. dayOfWeek = 1
  67. }
  68. tasks.named("createGitHubRelease") {
  69. repository {
  70. owner = "spring-projects"
  71. name = "spring-security"
  72. }
  73. }
  74. tasks.named("dispatchGitHubWorkflow") {
  75. repository {
  76. owner = "spring-projects"
  77. name = "spring-security"
  78. }
  79. }
  80. tasks.named("updateDependencies") {
  81. // we aren't Gradle 7 compatible yet
  82. checkForGradleUpdate = false
  83. }
  84. updateDependenciesSettings {
  85. gitHub {
  86. organization = "spring-projects"
  87. repository = "spring-security"
  88. }
  89. addFiles({
  90. return [
  91. project.file("buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy")
  92. ]
  93. })
  94. dependencyExcludes {
  95. majorVersionBump()
  96. alphaBetaVersions()
  97. snapshotVersions()
  98. addRule { components ->
  99. components.withModule("org.python:jython") { selection ->
  100. ModuleComponentIdentifier candidate = selection.getCandidate();
  101. if (!candidate.getVersion().equals(selection.getCurrentVersion())) {
  102. selection.reject("jython updates break integration tests");
  103. }
  104. }
  105. components.withModule("com.nimbusds:nimbus-jose-jwt") { selection ->
  106. ModuleComponentIdentifier candidate = selection.getCandidate();
  107. if (!candidate.getVersion().equals(selection.getCurrentVersion())) {
  108. selection.reject("nimbus-jose-jwt gets updated when oauth2-oidc-sdk is updated to ensure consistency");
  109. }
  110. }
  111. }
  112. }
  113. }
  114. def toolchainVersion() {
  115. if (project.hasProperty('testToolchain')) {
  116. return project.property('testToolchain').toString().toInteger()
  117. }
  118. return 17
  119. }
  120. subprojects {
  121. java {
  122. toolchain {
  123. languageVersion = JavaLanguageVersion.of(toolchainVersion())
  124. }
  125. }
  126. kotlin {
  127. jvmToolchain {
  128. languageVersion = JavaLanguageVersion.of(17)
  129. }
  130. }
  131. tasks.withType(JavaCompile).configureEach {
  132. options.encoding = "UTF-8"
  133. options.compilerArgs.add("-parameters")
  134. options.release.set(17)
  135. }
  136. }
  137. allprojects {
  138. if (!['spring-security-bom', 'spring-security-docs'].contains(project.name)) {
  139. apply plugin: 'io.spring.javaformat'
  140. apply plugin: 'checkstyle'
  141. pluginManager.withPlugin("io.spring.convention.checkstyle", { plugin ->
  142. configure(plugin) {
  143. dependencies {
  144. checkstyle libs.io.spring.javaformat.spring.javaformat.checkstyle
  145. }
  146. checkstyle {
  147. toolVersion = '8.34'
  148. }
  149. }
  150. })
  151. if (project.name.contains('sample')) {
  152. tasks.whenTaskAdded { task ->
  153. if (task.name.contains('format') || task.name.contains('checkFormat') || task.name.contains("checkstyle")) {
  154. task.enabled = false
  155. }
  156. }
  157. }
  158. }
  159. }
  160. if (hasProperty('buildScan')) {
  161. buildScan {
  162. termsOfServiceUrl = 'https://gradle.com/terms-of-service'
  163. termsOfServiceAgree = 'yes'
  164. }
  165. }
  166. nohttp {
  167. source.exclude "buildSrc/build/**"
  168. source.builtBy(project(':spring-security-config').tasks.withType(RncToXsd))
  169. }
  170. tasks.register('cloneSamples', IncludeRepoTask) {
  171. repository = 'spring-projects/spring-security-samples'
  172. ref = samplesBranch
  173. outputDirectory = project.hasProperty("cloneOutputDirectory") ? project.file("$cloneOutputDirectory") : project.file("build/samples")
  174. }
  175. s101 {
  176. configurationDirectory = project.file("etc/s101")
  177. }
  178. wrapperUpgrade {
  179. gradle {
  180. 'spring-security' {
  181. repo = 'spring-projects/spring-security'
  182. baseBranch = '6.0.x' // runs only on 6.0.x and the update is merged forward to main
  183. }
  184. }
  185. }