build.gradle 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. apply id: 'base'
  2. allprojects {
  3. version = '3.0.3.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 url: "$rootDir/gradle/javaprojects.gradle"
  18. apply url: "$rootDir/gradle/maven.gradle"
  19. }
  20. configure(coreModuleProjects) {
  21. apply url: "$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 url: "$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. task uploadApidocs(dependsOn: login) << {
  75. ant {
  76. scp(file: apitar.archivePath, todir: "$login.username@$sshHost:$remoteDocsDir", password: login.password)
  77. sshexec(host: sshHost, username: login.username, password: login.password, command: "cd $remoteDocsDir && tar -xjf ${apitar.archiveName}")
  78. sshexec(host: sshHost, username: login.username, password: login.password, command: "rm $remoteDocsDir/${apitar.archiveName}")
  79. }
  80. }
  81. task uploadManual(dependsOn: login) << {
  82. ant {
  83. scp(file: doctar.archivePath, todir: "$login.username@$sshHost:$remoteDocsDir", password: login.password)
  84. sshexec(host: sshHost, username: login.username, password: login.password, command: "cd $remoteDocsDir && tar -xjf ${doctar.archiveName}")
  85. sshexec(host: sshHost, username: login.username, password: login.password, command: "rm $remoteDocsDir/${doctar.archiveName}")
  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. }
  115. def getJavaProjects() {
  116. subprojects.findAll {project -> project.name != 'faq' && project.name != 'manual' }
  117. }
  118. def getSampleProjects() {
  119. subprojects.findAll {project -> project.name.startsWith('spring-security-samples') }
  120. }
  121. def getItestProjects() {
  122. subprojects.findAll {project -> project.name.startsWith('itest') }
  123. }
  124. def getCoreModuleProjects() {
  125. javaProjects - sampleProjects - itestProjects - aspectjProjects
  126. }
  127. def getAspectjProjects() {
  128. subprojects.findAll {project -> project.name == 'spring-security-aspects' || project.name == 'spring-security-samples-aspectj'}
  129. }
  130. class UploadDist extends DefaultTask {
  131. @InputFile
  132. File shaFile
  133. @InputFile
  134. File archiveFile
  135. @Input
  136. String archiveName
  137. @InputFiles
  138. def classpath
  139. @TaskAction
  140. def upload() {
  141. project.ant {
  142. taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: classpath.asPath)
  143. s3(accessKey: project.s3AccessKey, secretKey: project.s3SecretAccessKey) {
  144. upload(bucketName: 'dist.springframework.org', file: archiveFile,
  145. toFile: releaseType() + "/SEC/${archiveName}", publicRead: 'true') {
  146. metadata(name: 'project.name', value: 'Spring Security')
  147. metadata(name: 'release.type', value: releaseType())
  148. metadata(name: 'bundle.version', value: project.version)
  149. metadata(name: 'package.file.name', value: archiveName)
  150. }
  151. upload(bucketName: 'dist.springframework.org', file: shaFile,
  152. toFile: releaseType() + "/SEC/${archiveName}.sha1", publicRead: 'true')
  153. }
  154. }
  155. }
  156. def releaseType() {
  157. if (project.releaseBuild) {
  158. 'release'
  159. } else if (project.snapshotBuild) {
  160. 'snapshot'
  161. } else {
  162. 'milestone'
  163. }
  164. }
  165. }