javaprojects.gradle 8.3 KB

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