build.gradle 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. 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. host = sshHost
  48. }
  49. // Define remoteSiteDir and sshHost in gradle.properties
  50. def remoteDocsDir = null
  51. if (hasProperty('remoteSiteDir')) {
  52. remoteDocsDir="$remoteSiteDir/docs/3.1.x"
  53. }
  54. task uploadApidocs(type: TarUpload) {
  55. dependsOn apidocs
  56. classifier = 'apidocs'
  57. remoteDir = remoteDocsDir
  58. login = docSiteLogin
  59. into('apidocs') {
  60. from apidocs.destinationDir
  61. }
  62. }
  63. def docsDir = new File(project(':manual').buildDir, 'docs')
  64. task uploadDoc(type: TarUpload) {
  65. dependsOn ':manual:doc'
  66. classifier = 'doc'
  67. remoteDir = remoteDocsDir
  68. login = docSiteLogin
  69. into('reference') {
  70. from docsDir
  71. }
  72. }
  73. task uploadFaq(type: TarUpload) {
  74. dependsOn ':faq:docbookHtmlSingle'
  75. classifier = 'faq'
  76. remoteDir = project.property('remoteSiteDir')
  77. login = docSiteLogin
  78. def faqDir = new File(project(':faq').buildDir, 'docs')
  79. into('faq') {
  80. from faqDir
  81. }
  82. }
  83. task dist(type: Zip) {
  84. def zipRootDir = "${project.name}-$version"
  85. into(zipRootDir) {
  86. into('docs/apidocs') {
  87. from apidocs.destinationDir
  88. }
  89. into('docs/reference') {
  90. from docsDir
  91. }
  92. into('dist') {
  93. from coreModuleProjects.collect {project -> project.libsDir }
  94. from project(':spring-security-samples-tutorial').libsDir
  95. from project(':spring-security-samples-contacts').libsDir
  96. }
  97. }
  98. }
  99. dist {
  100. dependsOn apidocs, ':manual:doc', subprojects.collect { "$it.path:assemble" }
  101. doLast {
  102. ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
  103. }
  104. }
  105. task uploadDist(type: UploadDist) {
  106. archiveFile = dist.archivePath
  107. shaFile = "${dist.archivePath}.sha1" as File
  108. archiveName = dist.archiveName
  109. classpath = configurations.antlibs
  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 - aspectjProjects
  122. }
  123. def getAspectjProjects() {
  124. subprojects.findAll {project -> project.name == 'spring-security-aspects' || project.name == 'spring-security-samples-aspectj'}
  125. }
  126. class UploadDist extends DefaultTask {
  127. @InputFile
  128. File shaFile
  129. @InputFile
  130. File archiveFile
  131. @Input
  132. String archiveName
  133. @InputFiles
  134. def classpath
  135. @TaskAction
  136. def upload() {
  137. def accessKey = project.s3AccessKey
  138. def secretKey = project.s3SecretAccessKey
  139. def version = project.version
  140. project.ant {
  141. taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: classpath.asPath)
  142. s3(accessKey: accessKey, secretKey: secretKey) {
  143. upload(bucketName: 'dist.springframework.org', file: archiveFile,
  144. toFile: releaseType() + "/SEC/${archiveName}", publicRead: 'true') {
  145. metadata(name: 'project.name', value: 'Spring Security')
  146. metadata(name: 'release.type', value: releaseType())
  147. metadata(name: 'bundle.version', value: version)
  148. metadata(name: 'package.file.name', value: archiveName)
  149. }
  150. upload(bucketName: 'dist.springframework.org', file: shaFile,
  151. toFile: releaseType() + "/SEC/${archiveName}.sha1", publicRead: 'true')
  152. }
  153. }
  154. }
  155. def releaseType() {
  156. if (project.releaseBuild) {
  157. 'release'
  158. } else if (project.snapshotBuild) {
  159. 'snapshot'
  160. } else {
  161. 'milestone'
  162. }
  163. }
  164. }