javaprojects.gradle 9.0 KB

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