2
0

javaprojects.gradle 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.2'
  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. springSnapshotTestRuntime.extendsFrom testRuntime
  88. }
  89. configurations.springSnapshotTestRuntime {
  90. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  91. if (details.requested.group == 'org.springframework') {
  92. details.useVersion 'latest.integration'
  93. }
  94. }
  95. }
  96. sourceSets {
  97. integrationTest {
  98. java.srcDir file('src/integration-test/java')
  99. groovy.srcDirs file('src/integration-test/groovy')
  100. resources.srcDir file('src/integration-test/resources')
  101. compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
  102. runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
  103. }
  104. }
  105. task integrationTest(type: Test, dependsOn: jar) {
  106. testClassesDir = sourceSets.integrationTest.output.classesDir
  107. logging.captureStandardOutput(LogLevel.INFO)
  108. classpath = sourceSets.integrationTest.runtimeClasspath
  109. maxParallelForks = 1
  110. reports {
  111. html.destination = project.file("$project.buildDir/reports/integration-tests/")
  112. junitXml.destination = project.file("$project.buildDir/integration-test-results/")
  113. }
  114. }
  115. eclipse {
  116. classpath {
  117. plusConfigurations += [ configurations.integrationTestCompile ]
  118. }
  119. }
  120. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 1, project.configurations.getByName("integrationTestCompile"), Conf2ScopeMappingContainer.TEST)
  121. project.conf2ScopeMappings.addMapping(MavenPlugin.TEST_COMPILE_PRIORITY + 2, project.configurations.getByName("integrationTestRuntime"), Conf2ScopeMappingContainer.TEST)
  122. check.dependsOn integrationTest
  123. task springSnapshotTest(type: Test) {
  124. jvmArgs = ['-ea', '-Xmx500m', '-XX:MaxPermSize=128M']
  125. classpath = sourceSets.test.output + sourceSets.main.output + configurations.springSnapshotTestRuntime
  126. reports {
  127. html.destination = project.file("$buildDir/spring-snapshot-test-results/")
  128. junitXml.destination = project.file("$buildDir/reports/spring-snapshot-tests/")
  129. }
  130. }
  131. dependencies {
  132. optional "commons-logging:commons-logging:$commonsLoggingVersion"
  133. testCompile "junit:junit:$junitVersion",
  134. 'org.mockito:mockito-core:1.10.19',
  135. "org.springframework:spring-test:$springVersion",
  136. 'org.easytesting:fest-assert:1.4'
  137. // Use slf4j/logback for logging
  138. testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  139. "ch.qos.logback:logback-classic:$logbackVersion"
  140. }
  141. [configurations.runtime, configurations.default, configurations.testCompile]*.exclude(module: 'commons-logging')
  142. configurations.all {
  143. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  144. if (details.requested.group == 'org.slf4j') {
  145. details.useVersion slf4jVersion
  146. }
  147. }
  148. }
  149. [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  150. project.tasks.matching { it instanceof Test && it.name != 'integrationTest' }.all {
  151. jvmArgs = ['-ea', '-Xmx500m', '-XX:MaxPermSize=256M']
  152. maxParallelForks = guessMaxForks()
  153. logging.captureStandardOutput(LogLevel.INFO)
  154. }
  155. def guessMaxForks() {
  156. int processors = Runtime.runtime.availableProcessors()
  157. return Math.max(2, (int) (processors / 2))
  158. }
  159. jar {
  160. manifest.attributes["Created-By"] = 'Spring Security Team'
  161. manifest.attributes["Implementation-Title"] = project.name
  162. manifest.attributes["Implementation-Version"] = project.version
  163. manifest.attributes["Premain-Class"] =
  164. manifest.attributes["Agent-Class"] =
  165. manifest.attributes["Can-Redefine-Classes"] = "true"
  166. manifest.attributes["Can-Retransform-Classes"] = "true"
  167. manifest.attributes["Can-Set-Native-Method-Prefix"] = "false"
  168. }
  169. javadoc {
  170. title = "Spring Security $version API"
  171. source = sourceSets.main.allJava
  172. options {
  173. memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
  174. author = true
  175. header = project.name
  176. outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
  177. links = [
  178. "http://static.springsource.org/spring/docs/3.2.x/javadoc-api/",
  179. "http://static.springsource.org/spring-ldap/docs/1.3.x/apidocs/",
  180. "http://download.oracle.com/javase/6/docs/api/"
  181. ]
  182. groups = [
  183. 'Spring Security Core':[
  184. 'org.springframework.security.core*',
  185. 'org.springframework.security.authentication*',
  186. 'org.springframework.security.access*',
  187. 'org.springframework.security.remoting*',
  188. 'org.springframework.security.provisioning*',
  189. 'org.springframework.security.util*'],
  190. 'Spring Security Web':['org.springframework.security.web*'],
  191. 'Spring Security LDAP':['org.springframework.security.ldap*'],
  192. 'Spring Security Crypto':['org.springframework.security.crypto*'],
  193. 'Spring Security OpenID':['org.springframework.security.openid*'],
  194. 'Spring Security CAS':['org.springframework.security.cas*'],
  195. 'Spring Security ACL':['org.springframework.security.acls*'],
  196. 'Spring Security Config':['org.springframework.security.config*'],
  197. 'Spring Security Taglibs':['org.springframework.security.taglibs*'],
  198. ]
  199. }
  200. }
  201. eclipse.classpath.downloadSources = true
  202. // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
  203. eclipse.classpath {
  204. defaultOutputDir = file('bin/main')
  205. file.whenMerged { cp ->
  206. cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
  207. }
  208. }
  209. // GRADLE-1116
  210. project.eclipse.classpath.file.whenMerged { classpath ->
  211. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/test') }
  212. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  213. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/main') }
  214. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/main') }
  215. }
  216. // GRADLE-1422
  217. project.eclipseClasspath.doFirst {
  218. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  219. project.eclipse.classpath.file.whenMerged { classpath ->
  220. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  221. classpath.entries.each { cp ->
  222. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  223. def include = includeDeps.contains(cp.path)
  224. def attr = 'org.eclipse.jst.component.dependency'
  225. if(!include) {
  226. cp.entryAttributes.remove(attr)
  227. }
  228. }
  229. }
  230. }
  231. }
  232. project.idea.module {
  233. scopes.TEST.plus += [project.configurations.integrationTestRuntime]
  234. testSourceDirs += sourceSets.integrationTest.resources.srcDirs
  235. }
  236. task javadocJar(type: Jar) {
  237. classifier = 'javadoc'
  238. from javadoc
  239. }
  240. artifacts {
  241. archives javadocJar
  242. }