javaprojects.gradle 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.apacheDsVersion = '1.5.5'
  13. ext.aspectjVersion = '1.8.4'
  14. ext.casClientVersion = '3.3.3'
  15. ext.cglibVersion = '3.1'
  16. ext.commonsCodecVersion = '1.10'
  17. ext.commonsCollectionsVersion = '3.2.1'
  18. ext.commonsLoggingVersion = '1.2'
  19. ext.ehcacheVersion = '2.9.0'
  20. ext.gebVersion = '0.10.0'
  21. ext.groovyVersion = '2.3.8'
  22. ext.hsqlVersion = '2.3.2'
  23. ext.jacksonDatavindVersion = '2.4.4'
  24. ext.jettyVersion = '6.1.26'
  25. ext.jstlVersion = '1.2.1'
  26. ext.junitVersion = '4.11'
  27. ext.logbackVersion = '1.1.2'
  28. ext.powerMockVersion = '1.6.0'
  29. ext.seleniumVersion = '2.44.0'
  30. ext.servletApiVersion = '3.0.1'
  31. ext.slf4jVersion = '1.7.7'
  32. ext.spockVersion = '0.7-groovy-2.0'
  33. ext.springDataCommonsVersion = '1.9.1.RELEASE'
  34. ext.springDataJpaVersion = '1.7.1.RELEASE'
  35. ext.thymeleafVersion = '2.1.3.RELEASE'
  36. ext.spockDependencies = [
  37. dependencies.create("org.spockframework:spock-spring:$spockVersion") {
  38. exclude group: 'junit', module: 'junit-dep'
  39. },
  40. dependencies.create("org.spockframework:spock-core:$spockVersion") {
  41. exclude group: 'junit', module: 'junit-dep'
  42. }
  43. ]
  44. ext.gebDependencies = spockDependencies + [
  45. "org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
  46. "org.gebish:geb-spock:$gebVersion",
  47. 'commons-httpclient:commons-httpclient:3.1',
  48. "org.codehaus.groovy:groovy:$groovyVersion"
  49. ]
  50. ext.powerMockDependencies = [
  51. "org.powermock:powermock-core:$powerMockVersion",
  52. "org.powermock:powermock-api-support:$powerMockVersion",
  53. "org.powermock:powermock-module-junit4-common:$powerMockVersion",
  54. "org.powermock:powermock-module-junit4:$powerMockVersion",
  55. dependencies.create("org.powermock:powermock-api-mockito:$powerMockVersion") {
  56. exclude group: 'org.mockito', module: 'mockito-all'
  57. },
  58. "org.powermock:powermock-reflect:$powerMockVersion"
  59. ]
  60. ext.springCoreDependency = [
  61. dependencies.create("org.springframework:spring-core:$springVersion") {
  62. exclude(group: 'commons-logging', module: 'commons-logging')
  63. }
  64. ]
  65. ext.jstlDependencies = [
  66. "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:$jstlVersion",
  67. "org.apache.taglibs:taglibs-standard-jstlel:1.2.1"
  68. ]
  69. ext.apachedsDependencies = [
  70. "org.apache.directory.server:apacheds-core:$apacheDsVersion",
  71. "org.apache.directory.server:apacheds-core-entry:$apacheDsVersion",
  72. "org.apache.directory.server:apacheds-protocol-shared:$apacheDsVersion",
  73. "org.apache.directory.server:apacheds-protocol-ldap:$apacheDsVersion",
  74. "org.apache.directory.server:apacheds-server-jndi:$apacheDsVersion",
  75. 'org.apache.directory.shared:shared-ldap:0.9.15'
  76. ]
  77. // Integration test setup
  78. configurations {
  79. integrationTestCompile {
  80. extendsFrom testCompile, optional, provided
  81. }
  82. integrationTestRuntime {
  83. extendsFrom integrationTestCompile, testRuntime
  84. }
  85. }
  86. sourceSets {
  87. integrationTest {
  88. java.srcDir file('src/integration-test/java')
  89. groovy.srcDirs file('src/integration-test/groovy')
  90. resources.srcDir file('src/integration-test/resources')
  91. compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
  92. runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
  93. }
  94. }
  95. task integrationTest(type: Test, dependsOn: jar) {
  96. testClassesDir = sourceSets.integrationTest.output.classesDir
  97. logging.captureStandardOutput(LogLevel.INFO)
  98. classpath = sourceSets.integrationTest.runtimeClasspath
  99. maxParallelForks = 1
  100. reports {
  101. html.destination = project.file("$project.buildDir/reports/integration-tests/")
  102. junitXml.destination = project.file("$project.buildDir/integration-test-results/")
  103. }
  104. }
  105. eclipse {
  106. classpath {
  107. plusConfigurations += [ configurations.integrationTestCompile ]
  108. }
  109. }
  110. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 1, project.configurations.getByName("integrationTestCompile"), Conf2ScopeMappingContainer.TEST)
  111. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 2, project.configurations.getByName("integrationTestRuntime"), Conf2ScopeMappingContainer.TEST)
  112. check.dependsOn integrationTest
  113. dependencies {
  114. optional "commons-logging:commons-logging:$commonsLoggingVersion"
  115. testCompile "junit:junit:$junitVersion",
  116. 'org.mockito:mockito-core:1.9.5',
  117. "org.springframework:spring-test:$springVersion",
  118. 'org.easytesting:fest-assert:1.4'
  119. // Use slf4j/logback for logging
  120. testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  121. "ch.qos.logback:logback-classic:$logbackVersion"
  122. }
  123. [configurations.runtime, configurations.default, configurations.testCompile]*.exclude(module: 'commons-logging')
  124. configurations.all {
  125. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  126. if (details.requested.group == 'org.slf4j') {
  127. details.useVersion slf4jVersion
  128. }
  129. }
  130. }
  131. [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  132. project.tasks.matching { it instanceof Test && it.name != 'integrationTest' }.all {
  133. jvmArgs = ['-ea', '-Xmx500m', '-XX:MaxPermSize=256M']
  134. maxParallelForks = guessMaxForks()
  135. logging.captureStandardOutput(LogLevel.INFO)
  136. }
  137. def guessMaxForks() {
  138. int processors = Runtime.runtime.availableProcessors()
  139. return Math.max(2, (int) (processors / 2))
  140. }
  141. javadoc {
  142. title = "Spring Security $version API"
  143. source = sourceSets.main.allJava
  144. options {
  145. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
  146. author = true
  147. header = project.name
  148. outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
  149. links = [
  150. "http://static.springsource.org/spring/docs/3.2.x/javadoc-api/",
  151. "http://static.springsource.org/spring-ldap/docs/1.3.x/apidocs/",
  152. "http://download.oracle.com/javase/6/docs/api/"
  153. ]
  154. groups = [
  155. 'Spring Security Core':[
  156. 'org.springframework.security.core*',
  157. 'org.springframework.security.authentication*',
  158. 'org.springframework.security.access*',
  159. 'org.springframework.security.remoting*',
  160. 'org.springframework.security.provisioning*',
  161. 'org.springframework.security.util*'],
  162. 'Spring Security Web':['org.springframework.security.web*'],
  163. 'Spring Security LDAP':['org.springframework.security.ldap*'],
  164. 'Spring Security Crypto':['org.springframework.security.crypto*'],
  165. 'Spring Security OpenID':['org.springframework.security.openid*'],
  166. 'Spring Security CAS':['org.springframework.security.cas*'],
  167. 'Spring Security ACL':['org.springframework.security.acls*'],
  168. 'Spring Security Config':['org.springframework.security.config*'],
  169. 'Spring Security Taglibs':['org.springframework.security.taglibs*'],
  170. ]
  171. }
  172. }
  173. eclipse.classpath.downloadSources = true
  174. // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
  175. eclipse.classpath {
  176. defaultOutputDir = file('bin/main')
  177. file.whenMerged { cp ->
  178. cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
  179. }
  180. }
  181. // GRADLE-1116
  182. project.eclipse.classpath.file.whenMerged { classpath ->
  183. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/test') }
  184. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  185. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/main') }
  186. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/main') }
  187. }
  188. // GRADLE-1422
  189. project.eclipseClasspath.doFirst {
  190. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  191. project.eclipse.classpath.file.whenMerged { classpath ->
  192. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  193. classpath.entries.each { cp ->
  194. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  195. def include = includeDeps.contains(cp.path)
  196. def attr = 'org.eclipse.jst.component.dependency'
  197. if(!include) {
  198. cp.entryAttributes.remove(attr)
  199. }
  200. }
  201. }
  202. }
  203. }
  204. project.idea.module {
  205. scopes.TEST.plus += [project.configurations.integrationTestRuntime]
  206. testSourceDirs += sourceSets.integrationTest.resources.srcDirs
  207. }
  208. task javadocJar(type: Jar) {
  209. classifier = 'javadoc'
  210. from javadoc
  211. }
  212. artifacts {
  213. archives javadocJar
  214. }