2
0

ide-integration.gradle 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // STS-2723
  35. project(':spring-security-samples-aspectj') {
  36. task afterEclipseImport {
  37. ext.srcFile = file('.classpath')
  38. inputs.file srcFile
  39. outputs.dir srcFile
  40. onlyIf { srcFile.exists() }
  41. doLast {
  42. def classpath = new XmlParser().parse(srcFile)
  43. classpath.classpathentry.findAll{ it.@path == '/spring-security-aspects' }.each { node ->
  44. if(node.children().size() == 0) {
  45. def attrs = new Node(node,'attributes')
  46. def adjtAttr = new Node(attrs,'attributes',[name: 'org.eclipse.ajdt.aspectpath', value: 'org.eclipse.ajdt.aspectpath'])
  47. node.appendNode(adjtAttr)
  48. }
  49. }
  50. def writer = new FileWriter(srcFile)
  51. new XmlNodePrinter(new PrintWriter(writer)).print(classpath)
  52. }
  53. }
  54. }