javaprojects.gradle 7.5 KB

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