build.gradle 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. apply plugin: 'base'
  2. buildscript {
  3. repositories {
  4. mavenRepo urls: 'http://gradle.artifactoryonline.com/gradle/plugins'
  5. }
  6. dependencies {
  7. classpath "org.gradle.plugins:gradle-idea-plugin:0.3"
  8. }
  9. }
  10. allprojects {
  11. version = '3.1.0.CI-SNAPSHOT'
  12. releaseBuild = version.endsWith('RELEASE')
  13. snapshotBuild = version.endsWith('SNAPSHOT')
  14. group = 'org.springframework.security'
  15. repositories {
  16. mavenRepo name:'Local', urls: "file://" + System.properties['user.home'] + "/.m2/repository"
  17. mavenCentral()
  18. mavenRepo name: 'SpringSource Milestone Repo', urls: 'http://repository.springsource.com/maven/bundles/milestone'
  19. mavenRepo name: 'SpringSource Maven Snapshot Repo', urls: 'http://maven.springframework.org/snapshot/'
  20. mavenRepo name: 'SpringSource Enterprise Release', urls: 'http://repository.springsource.com/maven/bundles/release'
  21. mavenRepo name: 'SpringSource Enterprise External', urls: 'http://repository.springsource.com/maven/bundles/external'
  22. mavenRepo(name: 'Spock Snapshots', urls: 'http://m2repo.spockframework.org/snapshots')
  23. }
  24. }
  25. allprojects {
  26. apply plugin: 'org.gradle.idea'
  27. ideaModule {
  28. downloadJavadoc=false
  29. excludeDirs.add(buildDir)
  30. }
  31. def config = configurations.findByName('testRuntime')
  32. if (!config) {
  33. return
  34. }
  35. }
  36. ideaModule {
  37. excludeDirs.add(file('.gradle'))
  38. excludeDirs.add(file('buildSrc/build'))
  39. excludeDirs.add(file('buildSrc/.gradle'))
  40. }
  41. ideaProject {
  42. wildcards += ['?*.gradle']
  43. javaVersion = '1.6'
  44. }
  45. configure(javaProjects) {
  46. apply from: "$rootDir/gradle/javaprojects.gradle"
  47. apply from: "$rootDir/gradle/maven.gradle"
  48. }
  49. configure(coreModuleProjects) {
  50. apply from: "$rootDir/gradle/bundlor.gradle"
  51. // Gives better names in structure101 jar diagram
  52. sourceSets.main.classesDir = new File(buildDir, "classes/" + project.name.substring("spring-security".length() + 1))
  53. }
  54. configure (aspectjProjects) {
  55. apply from: "$rootDir/gradle/aspectj.gradle"
  56. }
  57. configurations {
  58. antlibs
  59. }
  60. dependencies {
  61. antlibs "org.springframework.build:org.springframework.build.aws.ant:3.0.3.RELEASE",
  62. "net.java.dev.jets3t:jets3t:0.6.1"
  63. }
  64. task apidocs(type: Javadoc) {
  65. destinationDir = new File(buildDir, 'apidocs')
  66. title = "Spring Security $version API"
  67. optionsFile = file("$buildDir/tmp/javadoc.options")
  68. source coreModuleProjects.collect {project ->
  69. project.sourceSets.main.allJava
  70. }
  71. classpath = files(coreModuleProjects.collect {project ->
  72. project.sourceSets.main.compileClasspath
  73. })
  74. }
  75. task docSiteLogin(type: Login) {
  76. if (project.hasProperty('sshHost')) {
  77. host = project.property('sshHost')
  78. }
  79. }
  80. // Define remoteSiteDir and sshHost in gradle.properties
  81. def remoteDocsDir = null
  82. if (hasProperty('remoteSiteDir')) {
  83. remoteDocsDir="$remoteSiteDir/docs/3.1.x"
  84. }
  85. task uploadApidocs(type: TarUpload) {
  86. dependsOn apidocs
  87. classifier = 'apidocs'
  88. remoteDir = remoteDocsDir
  89. login = docSiteLogin
  90. into('apidocs') {
  91. from apidocs.destinationDir
  92. }
  93. }
  94. def docsDir = new File(project(':manual').buildDir, 'docs')
  95. task uploadDoc(type: TarUpload) {
  96. dependsOn ':manual:doc'
  97. classifier = 'doc'
  98. remoteDir = remoteDocsDir
  99. login = docSiteLogin
  100. into('reference') {
  101. from docsDir
  102. }
  103. }
  104. task uploadFaq(type: TarUpload) {
  105. dependsOn ':faq:docbookHtmlSingle'
  106. classifier = 'faq'
  107. if (project.hasProperty('remoteSiteDir')) {
  108. remoteDir = project.property('remoteSiteDir')
  109. }
  110. login = docSiteLogin
  111. def faqDir = new File(project(':faq').buildDir, 'docs')
  112. into('faq') {
  113. from faqDir
  114. }
  115. }
  116. task dist(type: Zip) {
  117. def zipRootDir = "${project.name}-$version"
  118. into(zipRootDir) {
  119. into('docs/apidocs') {
  120. from apidocs.destinationDir
  121. }
  122. into('docs/reference') {
  123. from docsDir
  124. }
  125. into('dist') {
  126. from coreModuleProjects.collect {project -> project.libsDir }
  127. from project(':spring-security-samples-tutorial').libsDir
  128. from project(':spring-security-samples-contacts').libsDir
  129. }
  130. }
  131. }
  132. dist {
  133. dependsOn apidocs, ':manual:doc', subprojects.collect { "$it.path:assemble" }
  134. doLast {
  135. ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
  136. }
  137. }
  138. task uploadDist(type: UploadDist) {
  139. archiveFile = dist.archivePath
  140. shaFile = "${dist.archivePath}.sha1" as File
  141. archiveName = dist.archiveName
  142. classpath = configurations.antlibs
  143. }
  144. def getJavaProjects() {
  145. subprojects.findAll {project -> project.name != 'faq' && project.name != 'manual' }
  146. }
  147. def getSampleProjects() {
  148. subprojects.findAll {project -> project.name.startsWith('spring-security-samples') }
  149. }
  150. def getItestProjects() {
  151. subprojects.findAll {project -> project.name.startsWith('itest') }
  152. }
  153. def getCoreModuleProjects() {
  154. javaProjects - sampleProjects - itestProjects - aspectjProjects
  155. }
  156. def getAspectjProjects() {
  157. subprojects.findAll {project -> project.name == 'spring-security-aspects' || project.name == 'spring-security-samples-aspectj'}
  158. }
  159. class UploadDist extends DefaultTask {
  160. @InputFile
  161. File shaFile
  162. @InputFile
  163. File archiveFile
  164. @Input
  165. String archiveName
  166. @InputFiles
  167. def classpath
  168. @TaskAction
  169. def upload() {
  170. def accessKey = project.s3AccessKey
  171. def secretKey = project.s3SecretAccessKey
  172. def version = project.version
  173. project.ant {
  174. taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: classpath.asPath)
  175. s3(accessKey: accessKey, secretKey: secretKey) {
  176. upload(bucketName: 'dist.springframework.org', file: archiveFile,
  177. toFile: releaseType() + "/SEC/${archiveName}", publicRead: 'true') {
  178. metadata(name: 'project.name', value: 'Spring Security')
  179. metadata(name: 'release.type', value: releaseType())
  180. metadata(name: 'bundle.version', value: version)
  181. metadata(name: 'package.file.name', value: archiveName)
  182. }
  183. upload(bucketName: 'dist.springframework.org', file: shaFile,
  184. toFile: releaseType() + "/SEC/${archiveName}.sha1", publicRead: 'true')
  185. }
  186. }
  187. }
  188. def releaseType() {
  189. if (project.releaseBuild) {
  190. 'release'
  191. } else if (project.snapshotBuild) {
  192. 'snapshot'
  193. } else {
  194. 'milestone'
  195. }
  196. }
  197. }