2
0

ide-integration.gradle 3.2 KB

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