ide-integration.gradle 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import org.gradle.plugins.ide.eclipse.model.SourceFolder
  2. configure(allprojects) {
  3. apply plugin: 'idea'
  4. apply plugin: 'eclipse-wtp'
  5. eclipse.project.name = "${project.name}-3.2.x"
  6. }
  7. configure(javaProjects) {
  8. eclipse.classpath.downloadSources = true
  9. // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
  10. eclipse.classpath {
  11. defaultOutputDir = file('bin/main')
  12. file.whenMerged { cp ->
  13. cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
  14. }
  15. }
  16. // GRADLE-1422
  17. project.eclipseClasspath.doFirst {
  18. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  19. project.eclipse.classpath.file.whenMerged { classpath ->
  20. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  21. classpath.entries.each { cp ->
  22. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  23. def include = includeDeps.contains(cp.path)
  24. def attr = 'org.eclipse.jst.component.dependency'
  25. if(!include) {
  26. cp.entryAttributes.remove(attr)
  27. }
  28. }
  29. }
  30. }
  31. }
  32. tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
  33. project.eclipse.classpath.file.whenMerged { classpath->
  34. project.eclipse.wtp.component.file.whenMerged { wtpComponent ->
  35. wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
  36. }
  37. }
  38. }
  39. }
  40. // STS-3057
  41. configure(allprojects) {
  42. task afterEclipseImport {
  43. ext.srcFile = file('.classpath')
  44. inputs.file srcFile
  45. outputs.dir srcFile
  46. onlyIf { srcFile.exists() }
  47. doLast {
  48. def classpath = new XmlParser().parse(srcFile)
  49. classpath.classpathentry.findAll{ it.@path == 'GROOVY_SUPPORT' }.each { classpath.remove(it) }
  50. def writer = new FileWriter(srcFile)
  51. new XmlNodePrinter(new PrintWriter(writer)).print(classpath)
  52. }
  53. }
  54. }
  55. // STS-2723
  56. project(':spring-security-samples-xmlaspectj') {
  57. task afterEclipseImportAjdtFix {
  58. ext.srcFile = afterEclipseImport.srcFile
  59. inputs.file srcFile
  60. outputs.dir srcFile
  61. onlyIf { srcFile.exists() }
  62. doLast {
  63. def classpath = new XmlParser().parse(srcFile)
  64. classpath.classpathentry.findAll{ it.@path.startsWith('/spring-security-aspects') }.each { node ->
  65. if(node.children().size() == 0) {
  66. def attrs = new Node(node,'attributes')
  67. def adjtAttr = new Node(attrs,'attributes',[name: 'org.eclipse.ajdt.aspectpath', value: 'org.eclipse.ajdt.aspectpath'])
  68. node.appendNode(adjtAttr)
  69. }
  70. }
  71. def writer = new FileWriter(srcFile)
  72. new XmlNodePrinter(new PrintWriter(writer)).print(classpath)
  73. }
  74. }
  75. afterEclipseImport.dependsOn afterEclipseImportAjdtFix
  76. }