javaprojects.gradle 7.6 KB

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