ide-integration.gradle 2.3 KB

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