build.gradle 6.6 KB

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