javaprojects.gradle 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import org.gradle.plugins.ide.eclipse.model.SourceFolder
  2. apply plugin: 'java'
  3. apply plugin: 'javadocHotfix'
  4. apply plugin: 'eclipse-wtp'
  5. apply plugin: 'propdeps'
  6. apply plugin: 'propdeps-maven'
  7. apply plugin: 'propdeps-idea'
  8. apply plugin: 'propdeps-eclipse'
  9. sourceCompatibility = 1.5
  10. targetCompatibility = 1.5
  11. ext.ehcacheVersion = '1.6.2'
  12. ext.aspectjVersion = '1.6.10'
  13. ext.apacheDsVersion = '1.5.5'
  14. ext.jstlVersion = '1.2'
  15. ext.jettyVersion = '6.1.26'
  16. ext.hsqlVersion = '2.3.1'
  17. ext.slf4jVersion = '1.7.5'
  18. ext.logbackVersion = '0.9.29'
  19. ext.cglibVersion = '2.2'
  20. ext.powerMockVersion = '1.5.1'
  21. ext.servletApiVersion = '3.0.1'
  22. ext.seleniumVersion = '2.33.0'
  23. ext.groovyVersion = '2.0.5'
  24. ext.spockVersion = '0.7-groovy-2.0'
  25. ext.gebVersion = '0.9.0'
  26. ext.thymeleafVersion = '2.1.2.RELEASE'
  27. ext.spockDependencies = [
  28. dependencies.create("org.spockframework:spock-spring:$spockVersion") {
  29. exclude group: 'junit', module: 'junit-dep'
  30. },
  31. dependencies.create("org.spockframework:spock-core:$spockVersion") {
  32. exclude group: 'junit', module: 'junit-dep'
  33. }
  34. ]
  35. ext.powerMockDependencies = [
  36. "org.powermock:powermock-core:$powerMockVersion",
  37. "org.powermock:powermock-api-support:$powerMockVersion",
  38. "org.powermock:powermock-module-junit4-common:$powerMockVersion",
  39. "org.powermock:powermock-module-junit4:$powerMockVersion",
  40. dependencies.create("org.powermock:powermock-api-mockito:$powerMockVersion") {
  41. exclude group: 'org.mockito', module: 'mockito-all'
  42. },
  43. "org.powermock:powermock-reflect:$powerMockVersion"
  44. ]
  45. ext.apacheds_libs = [
  46. "org.apache.directory.server:apacheds-core:$apacheDsVersion",
  47. "org.apache.directory.server:apacheds-core-entry:$apacheDsVersion",
  48. "org.apache.directory.server:apacheds-protocol-shared:$apacheDsVersion",
  49. "org.apache.directory.server:apacheds-protocol-ldap:$apacheDsVersion",
  50. "org.apache.directory.server:apacheds-server-jndi:$apacheDsVersion",
  51. 'org.apache.directory.shared:shared-ldap:0.9.15'
  52. ]
  53. ext.bundlorProperties = [
  54. version: version,
  55. secRange: "[$version, 3.3.0)",
  56. springRange: "[$springVersion, 3.3.0)",
  57. aspectjRange: '[1.6.0, 1.8.0)',
  58. casRange: '[3.1.1, 3.2.0)',
  59. cloggingRange: '[1.0.4, 2.0.0)',
  60. ehcacheRange: '[1.4.1, 2.5.0)',
  61. openid4javaRange: '[0.9.5, 1.0.0)',
  62. springLdapRange: '[1.3.0,1.4.0)',
  63. apacheDSRange: '[1.5.5, 1.6)',
  64. apacheDSSharedRange: '[0.9.15, 1.0)',
  65. ldapSdkRange: '[4.1, 5.0)',
  66. aopAllianceRange: '[1.0.0, 2.0.0)'
  67. ]
  68. // Integration test setup
  69. configurations {
  70. integrationTestCompile {
  71. extendsFrom testCompile, optional, provided
  72. }
  73. integrationTestRuntime {
  74. extendsFrom integrationTestCompile, testRuntime
  75. }
  76. }
  77. sourceSets {
  78. integrationTest {
  79. java.srcDir file('src/integration-test/java')
  80. resources.srcDir file('src/integration-test/resources')
  81. compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
  82. runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
  83. }
  84. }
  85. task integrationTest(type: Test, dependsOn: jar) {
  86. testClassesDir = sourceSets.integrationTest.output.classesDir
  87. logging.captureStandardOutput(LogLevel.INFO)
  88. classpath = sourceSets.integrationTest.runtimeClasspath
  89. maxParallelForks = 1
  90. }
  91. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 1, project.configurations.getByName("integrationTestCompile"), Conf2ScopeMappingContainer.TEST)
  92. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 2, project.configurations.getByName("integrationTestRuntime"), Conf2ScopeMappingContainer.TEST)
  93. check.dependsOn integrationTest
  94. dependencies {
  95. optional 'commons-logging:commons-logging:1.1.1'
  96. compile ("org.springframework:spring-core:$springVersion") {
  97. exclude(group: 'commons-logging', module: 'commons-logging')
  98. }
  99. testCompile 'junit:junit:4.11',
  100. 'org.mockito:mockito-core:1.9.5',
  101. "org.springframework:spring-test:$springVersion",
  102. 'org.easytesting:fest-assert:1.4'
  103. // Use slf4j/logback for logging
  104. testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  105. "ch.qos.logback:logback-classic:$logbackVersion"
  106. }
  107. [configurations.runtime, configurations.default, configurations.testCompile]*.exclude(module: 'commons-logging')
  108. configurations.all {
  109. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  110. if (details.requested.group == 'org.slf4j') {
  111. details.useVersion slf4jVersion
  112. }
  113. }
  114. }
  115. [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  116. test {
  117. jvmArgs = ['-ea', '-Xmx500m', '-XX:MaxPermSize=128M']
  118. maxParallelForks = guessMaxForks()
  119. logging.captureStandardOutput(LogLevel.INFO)
  120. }
  121. def guessMaxForks() {
  122. int processors = Runtime.runtime.availableProcessors()
  123. return Math.max(2, (int) (processors / 2))
  124. }
  125. javadoc {
  126. title = "Spring Security $version API"
  127. source = sourceSets.main.allJava
  128. options {
  129. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
  130. author = true
  131. header = project.name
  132. outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
  133. links = [
  134. "http://static.springsource.org/spring/docs/3.2.x/javadoc-api/",
  135. "http://static.springsource.org/spring-ldap/docs/1.3.x/apidocs/",
  136. "http://download.oracle.com/javase/6/docs/api/"
  137. ]
  138. groups = [
  139. 'Spring Security Core':[
  140. 'org.springframework.security.core*',
  141. 'org.springframework.security.authentication*',
  142. 'org.springframework.security.access*',
  143. 'org.springframework.security.remoting*',
  144. 'org.springframework.security.provisioning*',
  145. 'org.springframework.security.util*'],
  146. 'Spring Security Web':['org.springframework.security.web*'],
  147. 'Spring Security LDAP':['org.springframework.security.ldap*'],
  148. 'Spring Security Crypto':['org.springframework.security.crypto*'],
  149. 'Spring Security OpenID':['org.springframework.security.openid*'],
  150. 'Spring Security CAS':['org.springframework.security.cas*'],
  151. 'Spring Security ACL':['org.springframework.security.acls*'],
  152. 'Spring Security Config':['org.springframework.security.config*'],
  153. 'Spring Security Taglibs':['org.springframework.security.taglibs*'],
  154. ]
  155. }
  156. }
  157. eclipse.classpath.downloadSources = true
  158. // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
  159. eclipse.classpath {
  160. defaultOutputDir = file('bin/main')
  161. file.whenMerged { cp ->
  162. cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
  163. }
  164. }
  165. // GRADLE-1116
  166. project.eclipse.classpath.file.whenMerged { classpath ->
  167. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/test') }
  168. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  169. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/main') }
  170. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/main') }
  171. }
  172. // GRADLE-1422
  173. project.eclipseClasspath.doFirst {
  174. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  175. project.eclipse.classpath.file.whenMerged { classpath ->
  176. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  177. classpath.entries.each { cp ->
  178. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  179. def include = includeDeps.contains(cp.path)
  180. def attr = 'org.eclipse.jst.component.dependency'
  181. if(!include) {
  182. cp.entryAttributes.remove(attr)
  183. }
  184. }
  185. }
  186. }
  187. }
  188. task javadocJar(type: Jar) {
  189. classifier = 'javadoc'
  190. from javadoc
  191. }
  192. artifacts {
  193. archives javadocJar
  194. }