ide-integration.gradle 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. apply plugin: 'idea'
  2. configure(javaProjects) {
  3. apply plugin: 'eclipse-wtp'
  4. eclipse.classpath.downloadSources = true
  5. // GRADLE-1116
  6. project.eclipse.classpath.file.whenMerged { classpath ->
  7. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  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-2723
  34. project(':spring-security-samples-aspectj') {
  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 == '/spring-security-aspects' }.each { node ->
  43. if(node.children().size() == 0) {
  44. def attrs = new Node(node,'attributes')
  45. def adjtAttr = new Node(attrs,'attributes',[name: 'org.eclipse.ajdt.aspectpath', value: 'org.eclipse.ajdt.aspectpath'])
  46. node.appendNode(adjtAttr)
  47. }
  48. }
  49. def writer = new FileWriter(srcFile)
  50. new XmlNodePrinter(new PrintWriter(writer)).print(classpath)
  51. }
  52. }
  53. }