ide-integration.gradle 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. apply plugin: 'idea'
  2. configure(javaProjects) {
  3. apply plugin: 'idea'
  4. apply plugin: 'eclipse-wtp'
  5. eclipse.classpath.downloadSources = true
  6. // GRADLE-1116
  7. project.eclipse.classpath.file.whenMerged { classpath ->
  8. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  9. }
  10. // GRADLE-1422
  11. project.eclipseClasspath.doFirst {
  12. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  13. project.eclipse.classpath.file.whenMerged { classpath ->
  14. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  15. classpath.entries.each { cp ->
  16. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  17. def include = includeDeps.contains(cp.path)
  18. def attr = 'org.eclipse.jst.component.dependency'
  19. if(!include) {
  20. cp.entryAttributes.remove(attr)
  21. }
  22. }
  23. }
  24. }
  25. }
  26. tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
  27. project.eclipse.classpath.file.whenMerged { classpath->
  28. project.eclipse.wtp.component.file.whenMerged { wtpComponent ->
  29. wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
  30. }
  31. }
  32. }
  33. }
  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. }