javaprojects.gradle 8.6 KB

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