2
0

javaprojects.gradle 8.4 KB

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