build.gradle 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import java.util.jar.Manifest
  2. import org.gradle.api.tasks.bundling.GradleManifest
  3. apply id: 'base'
  4. allprojects {
  5. version = '3.0.2.CI-SNAPSHOT'
  6. releaseBuild = version.endsWith('RELEASE')
  7. snapshotBuild = version.endsWith('SNAPSHOT')
  8. group = 'org.springframework.security'
  9. repositories {
  10. mavenRepo name:'Local', urls:'file:///Users/luke/.m2/repository'
  11. mavenCentral()
  12. // mavenRepo name:'SpringSource Milestone Repo', urls:'http://repository.springsource.com/maven/bundles/milestone'
  13. }
  14. }
  15. configure(javaProjects()) {
  16. apply id: 'java'
  17. springVersion = '3.0.0.RELEASE'
  18. springLdapVersion = '1.3.0.RELEASE'
  19. ehcacheVersion = '1.6.2'
  20. aspectjVersion = '1.6.5'
  21. apacheDsVersion = '1.5.5'
  22. jstlVersion = '1.1.2'
  23. configurations {
  24. bundlor
  25. provided
  26. }
  27. dependencies {
  28. compile 'commons-logging:commons-logging:1.1.1'
  29. testCompile 'junit:junit:4.7',
  30. 'org.mockito:mockito-core:1.7',
  31. 'org.jmock:jmock:2.5.1',
  32. 'org.jmock:jmock-junit4:2.5.1',
  33. 'org.hamcrest:hamcrest-core:1.1',
  34. 'org.hamcrest:hamcrest-library:1.1',
  35. "org.springframework:spring-test:$springVersion"
  36. bundlor 'com.springsource.bundlor:com.springsource.bundlor.ant:1.0.0.RC1',
  37. 'com.springsource.bundlor:com.springsource.bundlor:1.0.0.RC1',
  38. 'com.springsource.bundlor:com.springsource.bundlor.blint:1.0.0.RC1'
  39. }
  40. sourceSets {
  41. main {
  42. compileClasspath = compileClasspath + configurations.provided
  43. }
  44. test {
  45. compileClasspath = compileClasspath + configurations.provided
  46. runtimeClasspath = runtimeClasspath + configurations.provided
  47. }
  48. }
  49. test {
  50. options.fork(forkMode: ForkMode.ONCE, jvmArgs: ["-ea", '-Xms128m', '-Xmx500m', '-XX:MaxPermSize=128m', '-XX:+HeapDumpOnOutOfMemoryError'])
  51. }
  52. task bundlor (dependsOn: compileJava) << {
  53. if (!dependsOnTaskDidWork()) {
  54. return
  55. }
  56. ant.taskdef(resource: 'com/springsource/bundlor/ant/antlib.xml', classpath: configurations.bundlor.asPath)
  57. File template = new File(projectDir, 'template.mf')
  58. mkdir(buildDir, 'bundlor')
  59. if (template.exists()) {
  60. ant.bundlor(inputPath: "$buildDir/classes/main", outputPath: "$buildDir/bundlor", manifestTemplatePath: template) {
  61. property(name: 'version', value: "$version")
  62. property(name: 'spring.version', value: "$springVersion")
  63. }
  64. // See GRADLE-395 for support for using an existing manifest
  65. jar.manifest = new GradleManifest(new Manifest(new File("$buildDir/bundlor/META-INF/MANIFEST.MF").newInputStream()))
  66. }
  67. }
  68. jar.dependsOn bundlor
  69. }
  70. configure(javaProjects()) {
  71. apply id: 'maven'
  72. // Create a source jar for uploading
  73. task sourceJar(type: Jar) {
  74. classifier = 'sources'
  75. from sourceSets.main.java
  76. }
  77. configurations {
  78. deployerJars
  79. }
  80. artifacts {
  81. archives sourceJar
  82. }
  83. dependencies {
  84. deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:2.0.1.BUILD-SNAPSHOT"
  85. }
  86. uploadArchives {
  87. repositories.mavenDeployer {
  88. configuration = configurations.deployerJars
  89. if (releaseBuild) {
  90. // "mavenSyncRepoDir" should be set in properties
  91. repository(url: mavenSyncRepoDir)
  92. } else {
  93. s3credentials = [userName: s3AccessKey, passphrase: s3SecretAccessKey]
  94. repository(url: "s3://maven.springframework.org/milestone") {
  95. authentication(s3credentials)
  96. }
  97. snapshotRepository(url: "s3://maven.springframework.org/snapshot") {
  98. authentication(s3credentials)
  99. }
  100. }
  101. }
  102. }
  103. conf2ScopeMappings.addMapping(1, configurations.provided, "provided")
  104. }
  105. repositories {
  106. // Required for ant s3 task
  107. mavenRepo name: "s2.com release", urls: "http://repository.springsource.com/maven/bundles/release"
  108. }
  109. configurations {
  110. antlibs
  111. }
  112. dependencies {
  113. antlibs "org.springframework.build:org.springframework.build.aws.ant:3.0.3.RELEASE",
  114. "net.java.dev.jets3t:jets3t:0.6.1"
  115. }
  116. task apidocs(type: Javadoc) {
  117. destinationDir = new File(buildDir, 'apidocs')
  118. optionsFile = file("$buildDir/tmp/javadoc.options")
  119. source coreModuleProjects().collect { project ->
  120. project.sourceSets.main.allJava
  121. }
  122. classpath = files(coreModuleProjects().collect { project ->
  123. project.sourceSets.main.compileClasspath })
  124. }
  125. task apitar(type: Tar, dependsOn: apidocs) {
  126. compression = Compression.BZIP2
  127. classifier = 'apidocs'
  128. into('apidocs') {
  129. from apidocs.destinationDir
  130. }
  131. }
  132. task login << {
  133. ant.input("Please enter the ssh username for host '$sshHost'", addproperty: "ssh.username")
  134. ant.input("Please enter the ssh password '$sshHost'", addproperty: "ssh.password")
  135. def username = ant.properties['ssh.username']
  136. def password = ant.properties['ssh.password']
  137. }
  138. task uploadApidocs (dependsOn: login) << {
  139. ant.scp(file: apitar.archivePath, todir: "${login.username}@$sshHost:$remoteDocsDir", password: password)
  140. ant.sshexec(host: sshHost, username: login.username, password: login.password, command: "cd $remoteDocsDir && tar -xjf ${apitar.archiveName}")
  141. ant.sshexec(host: sshHost, username: login.username, password: login.password, command: "rm $remoteDocsDir/${apitar.archiveName}")
  142. }
  143. task dist (type: Zip) {
  144. def docsDir = new File(project(':manual').buildDir, 'docs')
  145. def zipRootDir = "${project.name}-$version"
  146. into (zipRootDir) {
  147. into('docs/apidocs') {
  148. from apidocs.destinationDir
  149. }
  150. into('docs/reference') {
  151. from docsDir
  152. }
  153. into('dist') {
  154. from coreModuleProjects().collect { project -> project.libsDir }
  155. from project(':spring-security-samples-tutorial').libsDir
  156. from project(':spring-security-samples-contacts').libsDir
  157. }
  158. }
  159. }
  160. dist.dependsOn apidocs, ':manual:doc'
  161. dist.dependsOn subprojects.collect { "$it.path:assemble" }
  162. dist.doLast {
  163. ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
  164. }
  165. task uploadDist << {
  166. def shaFile = file("${dist.archivePath}.sha1")
  167. assert dist.archivePath.isFile()
  168. assert shaFile.isFile()
  169. ant.taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: configurations.antlibs.asPath)
  170. ant.s3(accessKey: s3AccessKey, secretKey: s3SecretAccessKey) {
  171. upload(bucketName: 'dist.springframework.org', file: dist.archivePath,
  172. toFile: releaseType() + "/SEC/${dist.archiveName}", publicRead: 'true') {
  173. metadata(name: 'project.name', value: 'Spring Security')
  174. metadata(name: 'release.type', value: releaseType())
  175. metadata(name: 'bundle.version', value: version)
  176. metadata(name: 'package.file.name', value: dist.archiveName)
  177. }
  178. upload(bucketName: 'dist.springframework.org', file: shaFile,
  179. toFile: releaseType() + "/SEC/${dist.archiveName}.sha1", publicRead: 'true')
  180. }
  181. }
  182. def javaProjects() {
  183. subprojects.findAll { project -> project.name != 'faq' && project.name != 'manual' }
  184. }
  185. def sampleProjects() {
  186. subprojects.findAll { project -> project.name.startsWith('spring-security-samples') }
  187. }
  188. def coreModuleProjects() {
  189. javaProjects() - sampleProjects()
  190. }
  191. def releaseType() {
  192. if (releaseBuild) {
  193. 'release'
  194. } else if (snapshotBuild) {
  195. 'snapshot'
  196. } else {
  197. 'milestone'
  198. }
  199. }