build.gradle 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. }
  15. }
  16. configure(javaProjects) {
  17. apply from: "$rootDir/gradle/javaprojects.gradle"
  18. apply from: "$rootDir/gradle/maven.gradle"
  19. }
  20. configure(coreModuleProjects) {
  21. apply from: "$rootDir/gradle/bundlor.gradle"
  22. // Gives better names in structure101 jar diagram
  23. sourceSets.main.classesDir = new File(buildDir, "classes/" + project.name.substring("spring-security".length() + 1))
  24. }
  25. configure (aspectjProjects) {
  26. apply from: "$rootDir/gradle/aspectj.gradle"
  27. }
  28. configurations {
  29. antlibs
  30. }
  31. dependencies {
  32. antlibs "org.springframework.build:org.springframework.build.aws.ant:3.0.3.RELEASE",
  33. "net.java.dev.jets3t:jets3t:0.6.1"
  34. }
  35. def docsDir = new File(project(':manual').buildDir, 'docs')
  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 apitar(type: Tar, dependsOn: apidocs) {
  48. compression = Compression.BZIP2
  49. classifier = 'apidocs'
  50. into('apidocs') {
  51. from apidocs.destinationDir
  52. }
  53. }
  54. task doctar(type: Tar, dependsOn: ':manual:doc') {
  55. compression = Compression.BZIP2
  56. classifier = 'doc'
  57. into('reference') {
  58. from docsDir
  59. }
  60. }
  61. task login {
  62. // add dynamic properties to login task
  63. username = null
  64. password = null
  65. doFirst {
  66. ant {
  67. input("Please enter the ssh username for host '$sshHost'", addproperty: "ssh.username")
  68. input("Please enter the ssh password '$sshHost'", addproperty: "ssh.password")
  69. }
  70. username = ant.properties['ssh.username']
  71. password = ant.properties['ssh.password']
  72. }
  73. }
  74. // Define remoteSiteDir and sshHost in gradle.properties
  75. def remoteDocsDir = null
  76. if (hasProperty('remoteSiteDir')) {
  77. remoteDocsDir="$remoteSiteDir/docs/3.1.x"
  78. }
  79. task uploadApidocs(dependsOn: login) << {
  80. ant {
  81. scp(file: apitar.archivePath, todir: "$login.username@$sshHost:$remoteDocsDir", password: login.password)
  82. sshexec(host: sshHost, username: login.username, password: login.password, command: "cd $remoteDocsDir && tar -xjf ${apitar.archiveName}")
  83. sshexec(host: sshHost, username: login.username, password: login.password, command: "rm $remoteDocsDir/${apitar.archiveName}")
  84. }
  85. }
  86. task uploadManual(dependsOn: login) << {
  87. ant {
  88. scp(file: doctar.archivePath, todir: "$login.username@$sshHost:$remoteDocsDir", password: login.password)
  89. sshexec(host: sshHost, username: login.username, password: login.password, command: "cd $remoteDocsDir && tar -xjf ${doctar.archiveName}")
  90. sshexec(host: sshHost, username: login.username, password: login.password, command: "rm $remoteDocsDir/${doctar.archiveName}")
  91. }
  92. }
  93. task dist(type: Zip) {
  94. def zipRootDir = "${project.name}-$version"
  95. into(zipRootDir) {
  96. into('docs/apidocs') {
  97. from apidocs.destinationDir
  98. }
  99. into('docs/reference') {
  100. from docsDir
  101. }
  102. into('dist') {
  103. from coreModuleProjects.collect {project -> project.libsDir }
  104. from project(':spring-security-samples-tutorial').libsDir
  105. from project(':spring-security-samples-contacts').libsDir
  106. }
  107. }
  108. }
  109. dist {
  110. dependsOn apidocs, ':manual:doc', subprojects.collect { "$it.path:assemble" }
  111. doLast {
  112. ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
  113. }
  114. }
  115. task uploadDist(type: UploadDist) {
  116. archiveFile = dist.archivePath
  117. shaFile = "${dist.archivePath}.sha1" as File
  118. archiveName = dist.archiveName
  119. classpath = configurations.antlibs
  120. }
  121. def getJavaProjects() {
  122. subprojects.findAll {project -> project.name != 'faq' && project.name != 'manual' }
  123. }
  124. def getSampleProjects() {
  125. subprojects.findAll {project -> project.name.startsWith('spring-security-samples') }
  126. }
  127. def getItestProjects() {
  128. subprojects.findAll {project -> project.name.startsWith('itest') }
  129. }
  130. def getCoreModuleProjects() {
  131. javaProjects - sampleProjects - itestProjects - aspectjProjects
  132. }
  133. def getAspectjProjects() {
  134. subprojects.findAll {project -> project.name == 'spring-security-aspects' || project.name == 'spring-security-samples-aspectj'}
  135. }
  136. class UploadDist extends DefaultTask {
  137. @InputFile
  138. File shaFile
  139. @InputFile
  140. File archiveFile
  141. @Input
  142. String archiveName
  143. @InputFiles
  144. def classpath
  145. @TaskAction
  146. def upload() {
  147. def accessKey = project.s3AccessKey
  148. def secretKey = project.s3SecretAccessKey
  149. def version = project.version
  150. project.ant {
  151. taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: classpath.asPath)
  152. s3(accessKey: accessKey, secretKey: secretKey) {
  153. upload(bucketName: 'dist.springframework.org', file: archiveFile,
  154. toFile: releaseType() + "/SEC/${archiveName}", publicRead: 'true') {
  155. metadata(name: 'project.name', value: 'Spring Security')
  156. metadata(name: 'release.type', value: releaseType())
  157. metadata(name: 'bundle.version', value: version)
  158. metadata(name: 'package.file.name', value: archiveName)
  159. }
  160. upload(bucketName: 'dist.springframework.org', file: shaFile,
  161. toFile: releaseType() + "/SEC/${archiveName}.sha1", publicRead: 'true')
  162. }
  163. }
  164. }
  165. def releaseType() {
  166. if (project.releaseBuild) {
  167. 'release'
  168. } else if (project.snapshotBuild) {
  169. 'snapshot'
  170. } else {
  171. 'milestone'
  172. }
  173. }
  174. }