build.gradle 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. apply plugin: 'base'
  2. allprojects {
  3. version = '3.0.6.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. task apidocs(type: Javadoc) {
  36. destinationDir = new File(buildDir, 'apidocs')
  37. title = "Spring Security $version API"
  38. optionsFile = file("$buildDir/tmp/javadoc.options")
  39. source coreModuleProjects.collect {project ->
  40. project.sourceSets.main.allJava
  41. }
  42. classpath = files(coreModuleProjects.collect {project ->
  43. project.sourceSets.main.compileClasspath
  44. })
  45. }
  46. task docSiteLogin(type: Login) {
  47. if (project.hasProperty('sshHost')) {
  48. host = project.property('sshHost')
  49. }
  50. }
  51. // Define remoteSiteDir and sshHost in gradle.properties
  52. def remoteDocsDir = null
  53. if (hasProperty('remoteSiteDir')) {
  54. remoteDocsDir="$remoteSiteDir/docs/3.0.x"
  55. }
  56. task uploadApidocs(type: TarUpload) {
  57. dependsOn apidocs
  58. classifier = 'apidocs'
  59. remoteDir = remoteDocsDir
  60. login = docSiteLogin
  61. into('apidocs') {
  62. from apidocs.destinationDir
  63. }
  64. }
  65. def docsDir = new File(project(':manual').buildDir, 'docs')
  66. task uploadDoc(type: TarUpload) {
  67. dependsOn ':manual:doc'
  68. classifier = 'doc'
  69. remoteDir = remoteDocsDir
  70. login = docSiteLogin
  71. into('reference') {
  72. from docsDir
  73. }
  74. }
  75. task uploadFaq(type: TarUpload) {
  76. dependsOn ':faq:docbookHtmlSingle'
  77. classifier = 'faq'
  78. if (project.hasProperty('remoteSiteDir')) {
  79. remoteDir = project.property('remoteSiteDir')
  80. }
  81. login = docSiteLogin
  82. def faqDir = new File(project(':faq').buildDir, 'docs')
  83. into('faq') {
  84. from faqDir
  85. }
  86. }
  87. task dist(type: Zip) {
  88. def zipRootDir = "${project.name}-$version"
  89. into(zipRootDir) {
  90. into('docs/apidocs') {
  91. from apidocs.destinationDir
  92. }
  93. into('docs/reference') {
  94. from docsDir
  95. }
  96. into('dist') {
  97. from coreModuleProjects.collect {project -> project.libsDir }
  98. from project(':spring-security-samples-tutorial').libsDir
  99. from project(':spring-security-samples-contacts').libsDir
  100. }
  101. }
  102. }
  103. dist {
  104. dependsOn apidocs, ':manual:doc', subprojects.collect { "$it.path:assemble" }
  105. doLast {
  106. ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
  107. }
  108. }
  109. task uploadDist(type: UploadDist) {
  110. archiveFile = dist.archivePath
  111. shaFile = "${dist.archivePath}.sha1" as File
  112. archiveName = dist.archiveName
  113. classpath = configurations.antlibs
  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. def accessKey = project.s3AccessKey
  142. def secretKey = project.s3SecretAccessKey
  143. def version = project.version
  144. project.ant {
  145. taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: classpath.asPath)
  146. s3(accessKey: accessKey, secretKey: secretKey) {
  147. upload(bucketName: 'dist.springframework.org', file: archiveFile,
  148. toFile: releaseType() + "/SEC/${archiveName}", publicRead: 'true') {
  149. metadata(name: 'project.name', value: 'Spring Security')
  150. metadata(name: 'release.type', value: releaseType())
  151. metadata(name: 'bundle.version', value: version)
  152. metadata(name: 'package.file.name', value: archiveName)
  153. }
  154. upload(bucketName: 'dist.springframework.org', file: shaFile,
  155. toFile: releaseType() + "/SEC/${archiveName}.sha1", publicRead: 'true')
  156. }
  157. }
  158. }
  159. def releaseType() {
  160. if (project.releaseBuild) {
  161. 'release'
  162. } else if (project.snapshotBuild) {
  163. 'snapshot'
  164. } else {
  165. 'milestone'
  166. }
  167. }
  168. }