javaprojects.gradle 7.3 KB

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