javaprojects.gradle 8.7 KB

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