2
0

javaprojects.gradle 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import org.gradle.plugins.ide.eclipse.model.SourceFolder
  2. apply plugin: 'java'
  3. apply plugin: 'javadocHotfix'
  4. apply plugin: 'eclipse-wtp'
  5. apply plugin: 'propdeps'
  6. apply plugin: 'propdeps-maven'
  7. apply plugin: 'propdeps-idea'
  8. apply plugin: 'propdeps-eclipse'
  9. sourceCompatibility = 1.5
  10. targetCompatibility = 1.5
  11. ext.ehcacheVersion = '2.6.5'
  12. ext.aspectjVersion = '1.6.10'
  13. ext.apacheDsVersion = '1.5.5'
  14. ext.jstlVersion = '1.2'
  15. ext.jettyVersion = '6.1.26'
  16. ext.hsqlVersion = '2.3.1'
  17. ext.slf4jVersion = '1.7.5'
  18. ext.logbackVersion = '0.9.29'
  19. ext.cglibVersion = '2.2'
  20. ext.powerMockVersion = '1.5.1'
  21. ext.servletApiVersion = '7.0.33'
  22. ext.seleniumVersion = '2.33.0'
  23. ext.groovyVersion = '2.0.5'
  24. ext.spockVersion = '0.7-groovy-2.0'
  25. ext.gebVersion = '0.9.0'
  26. ext.thymeleafVersion = '2.1.2.RELEASE'
  27. ext.powerMockDependencies = [
  28. "org.powermock:powermock-core:$powerMockVersion",
  29. "org.powermock:powermock-api-support:$powerMockVersion",
  30. "org.powermock:powermock-module-junit4-common:$powerMockVersion",
  31. "org.powermock:powermock-module-junit4:$powerMockVersion",
  32. "org.powermock:powermock-api-mockito:$powerMockVersion",
  33. "org.powermock:powermock-reflect:$powerMockVersion"
  34. ]
  35. ext.apacheds_libs = [
  36. "org.apache.directory.server:apacheds-core:$apacheDsVersion",
  37. "org.apache.directory.server:apacheds-core-entry:$apacheDsVersion",
  38. "org.apache.directory.server:apacheds-protocol-shared:$apacheDsVersion",
  39. "org.apache.directory.server:apacheds-protocol-ldap:$apacheDsVersion",
  40. "org.apache.directory.server:apacheds-server-jndi:$apacheDsVersion",
  41. 'org.apache.directory.shared:shared-ldap:0.9.15'
  42. ]
  43. // Integration test setup
  44. configurations {
  45. integrationTestCompile {
  46. extendsFrom testCompile, optional, provided
  47. }
  48. integrationTestRuntime {
  49. extendsFrom integrationTestCompile, testRuntime
  50. }
  51. }
  52. sourceSets {
  53. integrationTest {
  54. java.srcDir file('src/integration-test/java')
  55. resources.srcDir file('src/integration-test/resources')
  56. compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
  57. runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
  58. }
  59. }
  60. task integrationTest(type: Test, dependsOn: jar) {
  61. testClassesDir = sourceSets.integrationTest.output.classesDir
  62. logging.captureStandardOutput(LogLevel.INFO)
  63. classpath = sourceSets.integrationTest.runtimeClasspath
  64. maxParallelForks = 1
  65. }
  66. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 1, project.configurations.getByName("integrationTestCompile"), Conf2ScopeMappingContainer.TEST)
  67. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 2, project.configurations.getByName("integrationTestRuntime"), Conf2ScopeMappingContainer.TEST)
  68. check.dependsOn integrationTest
  69. dependencies {
  70. optional 'commons-logging:commons-logging:1.1.1'
  71. compile ("org.springframework:spring-core:$springVersion") {
  72. exclude(group: 'commons-logging', module: 'commons-logging')
  73. }
  74. testCompile 'junit:junit:4.10',
  75. 'org.mockito:mockito-core:1.9.5',
  76. "org.springframework:spring-test:$springVersion",
  77. 'org.easytesting:fest-assert:1.4'
  78. // Use slf4j/logback for logging
  79. testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  80. "ch.qos.logback:logback-classic:$logbackVersion"
  81. }
  82. [configurations.runtime, configurations.default]*.exclude(module: 'commons-logging')
  83. configurations.all {
  84. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  85. if (details.requested.group == 'org.slf4j') {
  86. details.useVersion slf4jVersion
  87. }
  88. }
  89. }
  90. [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  91. test {
  92. jvmArgs = ['-ea', '-Xmx500m', '-XX:MaxPermSize=128M']
  93. maxParallelForks = guessMaxForks()
  94. logging.captureStandardOutput(LogLevel.INFO)
  95. }
  96. def guessMaxForks() {
  97. int processors = Runtime.runtime.availableProcessors()
  98. return Math.max(2, (int) (processors / 2))
  99. }
  100. javadoc {
  101. title = "Spring Security $version API"
  102. source = sourceSets.main.allJava
  103. options {
  104. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
  105. author = true
  106. header = project.name
  107. outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
  108. links = [
  109. "http://static.springsource.org/spring/docs/3.2.x/javadoc-api/",
  110. "http://static.springsource.org/spring-ldap/docs/1.3.x/apidocs/",
  111. "http://download.oracle.com/javase/6/docs/api/"
  112. ]
  113. groups = [
  114. 'Spring Security Core':[
  115. 'org.springframework.security.core*',
  116. 'org.springframework.security.authentication*',
  117. 'org.springframework.security.access*',
  118. 'org.springframework.security.remoting*',
  119. 'org.springframework.security.provisioning*',
  120. 'org.springframework.security.util*'],
  121. 'Spring Security Web':['org.springframework.security.web*'],
  122. 'Spring Security LDAP':['org.springframework.security.ldap*'],
  123. 'Spring Security Crypto':['org.springframework.security.crypto*'],
  124. 'Spring Security OpenID':['org.springframework.security.openid*'],
  125. 'Spring Security CAS':['org.springframework.security.cas*'],
  126. 'Spring Security ACL':['org.springframework.security.acls*'],
  127. 'Spring Security Config':['org.springframework.security.config*'],
  128. 'Spring Security Taglibs':['org.springframework.security.taglibs*'],
  129. ]
  130. }
  131. }
  132. eclipse.classpath.downloadSources = true
  133. // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
  134. eclipse.classpath {
  135. defaultOutputDir = file('bin/main')
  136. file.whenMerged { cp ->
  137. cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
  138. }
  139. }
  140. // GRADLE-1116
  141. project.eclipse.classpath.file.whenMerged { classpath ->
  142. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/test') }
  143. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  144. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/main') }
  145. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/main') }
  146. }
  147. // GRADLE-1422
  148. project.eclipseClasspath.doFirst {
  149. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  150. project.eclipse.classpath.file.whenMerged { classpath ->
  151. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  152. classpath.entries.each { cp ->
  153. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  154. def include = includeDeps.contains(cp.path)
  155. def attr = 'org.eclipse.jst.component.dependency'
  156. if(!include) {
  157. cp.entryAttributes.remove(attr)
  158. }
  159. }
  160. }
  161. }
  162. }
  163. task javadocJar(type: Jar) {
  164. classifier = 'javadoc'
  165. from javadoc
  166. }
  167. artifacts {
  168. archives javadocJar
  169. }