ide-integration.gradle 2.7 KB

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