build.gradle 8.4 KB

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