build.gradle 6.0 KB

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