javaprojects.gradle 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. apply plugin: 'java'
  2. apply plugin: 'groovy'
  3. apply plugin: 'javadocHotfix'
  4. apply plugin: 'propdeps'
  5. apply plugin: 'propdeps-maven'
  6. sourceCompatibility = 1.6
  7. targetCompatibility = 1.6
  8. ext.apacheDsVersion = '1.5.5'
  9. ext.aspectjVersion = '1.8.4'
  10. ext.casClientVersion = '3.4.1'
  11. ext.cglibVersion = '3.1'
  12. ext.commonsCodecVersion = '1.10'
  13. ext.commonsCollectionsVersion = '3.2.2'
  14. ext.commonsLoggingVersion = '1.2'
  15. ext.ehcacheVersion = '2.9.0'
  16. ext.gebVersion = '0.10.0'
  17. ext.groovyVersion = '2.4.4'
  18. ext.hsqlVersion = '2.3.2'
  19. ext.jacksonDatavindVersion = '2.4.4'
  20. ext.jettyVersion = '6.1.26'
  21. ext.jstlVersion = '1.2.1'
  22. ext.junitVersion = '4.12'
  23. ext.logbackVersion = '1.1.2'
  24. ext.powerMockVersion = '1.6.2'
  25. ext.seleniumVersion = '2.44.0'
  26. ext.servletApiVersion = '3.0.1'
  27. ext.slf4jVersion = '1.7.7'
  28. ext.spockVersion = '0.7-groovy-2.0'
  29. ext.springDataCommonsVersion = '1.9.1.RELEASE'
  30. ext.springDataJpaVersion = '1.7.1.RELEASE'
  31. ext.springDataRedisVersion = '1.4.1.RELEASE'
  32. ext.springSessionVersion = '1.0.0.RELEASE'
  33. ext.thymeleafVersion = '2.1.4.RELEASE'
  34. ext.spockDependencies = [
  35. dependencies.create("org.spockframework:spock-spring:$spockVersion") {
  36. exclude group: 'junit', module: 'junit-dep'
  37. },
  38. dependencies.create("org.spockframework:spock-core:$spockVersion") {
  39. exclude group: 'junit', module: 'junit-dep'
  40. }
  41. ]
  42. ext.gebDependencies = spockDependencies + [
  43. "org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
  44. "org.gebish:geb-spock:$gebVersion",
  45. 'commons-httpclient:commons-httpclient:3.1',
  46. "org.codehaus.groovy:groovy:$groovyVersion",
  47. "org.codehaus.groovy:groovy-all:$groovyVersion"
  48. ]
  49. ext.powerMockDependencies = [
  50. "org.powermock:powermock-core:$powerMockVersion",
  51. "org.powermock:powermock-api-support:$powerMockVersion",
  52. "org.powermock:powermock-module-junit4-common:$powerMockVersion",
  53. "org.powermock:powermock-module-junit4:$powerMockVersion",
  54. dependencies.create("org.powermock:powermock-api-mockito:$powerMockVersion") {
  55. exclude group: 'org.mockito', module: 'mockito-all'
  56. },
  57. "org.powermock:powermock-reflect:$powerMockVersion"
  58. ]
  59. ext.springCoreDependency = [
  60. dependencies.create("org.springframework:spring-core:$springVersion") {
  61. exclude(group: 'commons-logging', module: 'commons-logging')
  62. }
  63. ]
  64. ext.jstlDependencies = [
  65. "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:$jstlVersion",
  66. "org.apache.taglibs:taglibs-standard-jstlel:1.2.1"
  67. ]
  68. ext.apachedsDependencies = [
  69. "org.apache.directory.server:apacheds-core:$apacheDsVersion",
  70. "org.apache.directory.server:apacheds-core-entry:$apacheDsVersion",
  71. "org.apache.directory.server:apacheds-protocol-shared:$apacheDsVersion",
  72. "org.apache.directory.server:apacheds-protocol-ldap:$apacheDsVersion",
  73. "org.apache.directory.server:apacheds-server-jndi:$apacheDsVersion",
  74. 'org.apache.directory.shared:shared-ldap:0.9.15'
  75. ]
  76. // Integration test setup
  77. configurations {
  78. integrationTestCompile {
  79. extendsFrom testCompile, optional, provided
  80. }
  81. integrationTestRuntime {
  82. extendsFrom integrationTestCompile, testRuntime
  83. }
  84. springSnapshotTestRuntime.extendsFrom testRuntime
  85. }
  86. configurations.springSnapshotTestRuntime {
  87. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  88. if (details.requested.group == 'org.springframework') {
  89. details.useVersion 'latest.integration'
  90. }
  91. }
  92. }
  93. sourceSets {
  94. integrationTest {
  95. java.srcDir file('src/integration-test/java')
  96. groovy.srcDirs file('src/integration-test/groovy')
  97. resources.srcDir file('src/integration-test/resources')
  98. compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
  99. runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
  100. }
  101. }
  102. task integrationTest(type: Test, dependsOn: jar) {
  103. testClassesDir = sourceSets.integrationTest.output.classesDir
  104. logging.captureStandardOutput(LogLevel.INFO)
  105. classpath = sourceSets.integrationTest.runtimeClasspath
  106. maxParallelForks = 1
  107. reports {
  108. html.destination = project.file("$project.buildDir/reports/integration-tests/")
  109. junitXml.destination = project.file("$project.buildDir/integration-test-results/")
  110. }
  111. }
  112. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 1, project.configurations.getByName("integrationTestCompile"), Conf2ScopeMappingContainer.TEST)
  113. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 2, project.configurations.getByName("integrationTestRuntime"), Conf2ScopeMappingContainer.TEST)
  114. check.dependsOn integrationTest
  115. task springSnapshotTest(type: Test) {
  116. jvmArgs = ['-ea', '-Xmx500m']
  117. classpath = sourceSets.test.output + sourceSets.main.output + configurations.springSnapshotTestRuntime
  118. reports {
  119. html.destination = project.file("$buildDir/spring-snapshot-test-results/")
  120. junitXml.destination = project.file("$buildDir/reports/spring-snapshot-tests/")
  121. }
  122. }
  123. dependencies {
  124. optional "commons-logging:commons-logging:$commonsLoggingVersion"
  125. testCompile "junit:junit:$junitVersion",
  126. 'org.mockito:mockito-core:1.10.19',
  127. "org.springframework:spring-test:$springVersion",
  128. 'org.assertj:assertj-core:2.2.0'
  129. // Use slf4j/logback for logging
  130. testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  131. "ch.qos.logback:logback-classic:$logbackVersion"
  132. }
  133. [configurations.runtime, configurations.default, configurations.testCompile]*.exclude(module: 'commons-logging')
  134. configurations.all {
  135. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  136. if (details.requested.group == 'org.slf4j') {
  137. details.useVersion slf4jVersion
  138. }
  139. }
  140. }
  141. [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  142. project.tasks.matching { it instanceof Test && it.name != 'integrationTest' }.all {
  143. jvmArgs = ['-ea', '-Xmx500m']
  144. maxParallelForks = guessMaxForks()
  145. logging.captureStandardOutput(LogLevel.INFO)
  146. }
  147. def guessMaxForks() {
  148. int processors = Runtime.runtime.availableProcessors()
  149. return Math.max(2, (int) (processors / 2))
  150. }
  151. jar {
  152. manifest.attributes["Created-By"] = 'Spring Security Team'
  153. manifest.attributes["Implementation-Title"] = project.name
  154. manifest.attributes["Implementation-Version"] = project.version
  155. manifest.attributes["Premain-Class"] =
  156. manifest.attributes["Agent-Class"] =
  157. manifest.attributes["Can-Redefine-Classes"] = "true"
  158. manifest.attributes["Can-Retransform-Classes"] = "true"
  159. manifest.attributes["Can-Set-Native-Method-Prefix"] = "false"
  160. }
  161. javadoc {
  162. title = "Spring Security $version API"
  163. source = sourceSets.main.allJava
  164. logging.captureStandardError LogLevel.INFO
  165. logging.captureStandardOutput LogLevel.INFO
  166. options {
  167. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
  168. author = true
  169. header = project.name
  170. outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
  171. links = [
  172. "http://static.springsource.org/spring/docs/3.2.x/javadoc-api/",
  173. "http://static.springsource.org/spring-ldap/docs/1.3.x/apidocs/",
  174. "http://download.oracle.com/javase/6/docs/api/"
  175. ]
  176. groups = [
  177. 'Spring Security Core':[
  178. 'org.springframework.security.core*',
  179. 'org.springframework.security.authentication*',
  180. 'org.springframework.security.access*',
  181. 'org.springframework.security.remoting*',
  182. 'org.springframework.security.provisioning*',
  183. 'org.springframework.security.util*'],
  184. 'Spring Security Web':['org.springframework.security.web*'],
  185. 'Spring Security LDAP':['org.springframework.security.ldap*'],
  186. 'Spring Security Crypto':['org.springframework.security.crypto*'],
  187. 'Spring Security OpenID':['org.springframework.security.openid*'],
  188. 'Spring Security CAS':['org.springframework.security.cas*'],
  189. 'Spring Security ACL':['org.springframework.security.acls*'],
  190. 'Spring Security Config':['org.springframework.security.config*'],
  191. 'Spring Security Taglibs':['org.springframework.security.taglibs*'],
  192. ]
  193. addStringOption('-quiet')
  194. }
  195. }
  196. task javadocJar(type: Jar) {
  197. classifier = 'javadoc'
  198. from javadoc
  199. }
  200. artifacts {
  201. archives javadocJar
  202. }