build.gradle 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. apply plugin: 'base'
  2. allprojects {
  3. version = '3.1.0.CI-SNAPSHOT'
  4. releaseBuild = version.endsWith('RELEASE')
  5. snapshotBuild = version.endsWith('SNAPSHOT')
  6. group = 'org.springframework.security'
  7. repositories {
  8. mavenRepo name:'Local', urls: "file://" + System.properties['user.home'] + "/.m2/repository"
  9. mavenCentral()
  10. mavenRepo name: 'SpringSource Milestone Repo', urls: 'http://repository.springsource.com/maven/bundles/milestone'
  11. mavenRepo name: 'SpringSource Maven Snapshot Repo', urls: 'http://maven.springframework.org/snapshot/'
  12. mavenRepo name: 'SpringSource Enterprise Release', urls: 'http://repository.springsource.com/maven/bundles/release'
  13. mavenRepo name: 'SpringSource Enterprise External', urls: 'http://repository.springsource.com/maven/bundles/external'
  14. mavenRepo(name: 'Spock Snapshots', urls: 'http://m2repo.spockframework.org/snapshots')
  15. }
  16. }
  17. configure(javaProjects) {
  18. apply from: "$rootDir/gradle/javaprojects.gradle"
  19. apply from: "$rootDir/gradle/maven.gradle"
  20. }
  21. configure(coreModuleProjects) {
  22. apply from: "$rootDir/gradle/bundlor.gradle"
  23. // Gives better names in structure101 jar diagram
  24. sourceSets.main.classesDir = new File(buildDir, "classes/" + project.name.substring("spring-security".length() + 1))
  25. }
  26. configure (aspectjProjects) {
  27. apply from: "$rootDir/gradle/aspectj.gradle"
  28. }
  29. configurations {
  30. antlibs
  31. }
  32. dependencies {
  33. antlibs "org.springframework.build:org.springframework.build.aws.ant:3.0.3.RELEASE",
  34. "net.java.dev.jets3t:jets3t:0.6.1"
  35. }
  36. task apidocs(type: Javadoc) {
  37. destinationDir = new File(buildDir, 'apidocs')
  38. title = "Spring Security $version API"
  39. optionsFile = file("$buildDir/tmp/javadoc.options")
  40. source coreModuleProjects.collect {project ->
  41. project.sourceSets.main.allJava
  42. }
  43. classpath = files(coreModuleProjects.collect {project ->
  44. project.sourceSets.main.compileClasspath
  45. })
  46. }
  47. task docSiteLogin(type: Login) {
  48. if (project.hasProperty('sshHost')) {
  49. host = project.property('sshHost')
  50. }
  51. }
  52. // Define remoteSiteDir and sshHost in gradle.properties
  53. def remoteDocsDir = null
  54. if (hasProperty('remoteSiteDir')) {
  55. remoteDocsDir="$remoteSiteDir/docs/3.1.x"
  56. }
  57. task uploadApidocs(type: TarUpload) {
  58. dependsOn apidocs
  59. classifier = 'apidocs'
  60. remoteDir = remoteDocsDir
  61. login = docSiteLogin
  62. into('apidocs') {
  63. from apidocs.destinationDir
  64. }
  65. }
  66. def docsDir = new File(project(':manual').buildDir, 'docs')
  67. task uploadDoc(type: TarUpload) {
  68. dependsOn ':manual:doc'
  69. classifier = 'doc'
  70. remoteDir = remoteDocsDir
  71. login = docSiteLogin
  72. into('reference') {
  73. from docsDir
  74. }
  75. }
  76. task uploadFaq(type: TarUpload) {
  77. dependsOn ':faq:docbookHtmlSingle'
  78. classifier = 'faq'
  79. if (project.hasProperty('remoteSiteDir')) {
  80. remoteDir = project.property('remoteSiteDir')
  81. }
  82. login = docSiteLogin
  83. def faqDir = new File(project(':faq').buildDir, 'docs')
  84. into('faq') {
  85. from faqDir
  86. }
  87. }
  88. task dist(type: Zip) {
  89. def zipRootDir = "${project.name}-$version"
  90. into(zipRootDir) {
  91. into('docs/apidocs') {
  92. from apidocs.destinationDir
  93. }
  94. into('docs/reference') {
  95. from docsDir
  96. }
  97. into('dist') {
  98. from coreModuleProjects.collect {project -> project.libsDir }
  99. from project(':spring-security-samples-tutorial').libsDir
  100. from project(':spring-security-samples-contacts').libsDir
  101. }
  102. }
  103. }
  104. dist {
  105. dependsOn apidocs, ':manual:doc', subprojects.collect { "$it.path:assemble" }
  106. doLast {
  107. ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
  108. }
  109. }
  110. task uploadDist(type: UploadDist) {
  111. archiveFile = dist.archivePath
  112. shaFile = "${dist.archivePath}.sha1" as File
  113. archiveName = dist.archiveName
  114. classpath = configurations.antlibs
  115. }
  116. def getJavaProjects() {
  117. subprojects.findAll {project -> project.name != 'faq' && project.name != 'manual' }
  118. }
  119. def getSampleProjects() {
  120. subprojects.findAll {project -> project.name.startsWith('spring-security-samples') }
  121. }
  122. def getItestProjects() {
  123. subprojects.findAll {project -> project.name.startsWith('itest') }
  124. }
  125. def getCoreModuleProjects() {
  126. javaProjects - sampleProjects - itestProjects - aspectjProjects
  127. }
  128. def getAspectjProjects() {
  129. subprojects.findAll {project -> project.name == 'spring-security-aspects' || project.name == 'spring-security-samples-aspectj'}
  130. }
  131. class UploadDist extends DefaultTask {
  132. @InputFile
  133. File shaFile
  134. @InputFile
  135. File archiveFile
  136. @Input
  137. String archiveName
  138. @InputFiles
  139. def classpath
  140. @TaskAction
  141. def upload() {
  142. def accessKey = project.s3AccessKey
  143. def secretKey = project.s3SecretAccessKey
  144. def version = project.version
  145. project.ant {
  146. taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: classpath.asPath)
  147. s3(accessKey: accessKey, secretKey: secretKey) {
  148. upload(bucketName: 'dist.springframework.org', file: archiveFile,
  149. toFile: releaseType() + "/SEC/${archiveName}", publicRead: 'true') {
  150. metadata(name: 'project.name', value: 'Spring Security')
  151. metadata(name: 'release.type', value: releaseType())
  152. metadata(name: 'bundle.version', value: version)
  153. metadata(name: 'package.file.name', value: archiveName)
  154. }
  155. upload(bucketName: 'dist.springframework.org', file: shaFile,
  156. toFile: releaseType() + "/SEC/${archiveName}.sha1", publicRead: 'true')
  157. }
  158. }
  159. }
  160. def releaseType() {
  161. if (project.releaseBuild) {
  162. 'release'
  163. } else if (project.snapshotBuild) {
  164. 'snapshot'
  165. } else {
  166. 'milestone'
  167. }
  168. }
  169. }