javaprojects.gradle 8.7 KB

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