ide-integration.gradle 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. apply plugin: 'idea'
  2. configure(javaProjects) {
  3. apply plugin: 'idea'
  4. apply plugin: 'eclipse'
  5. ideaModule {
  6. downloadJavadoc=false
  7. excludeDirs.add(buildDir)
  8. gradleCacheVariable = 'GRADLE_CACHE'
  9. outputDir = "$rootProject.projectDir/intellij/out" as File
  10. testOutputDir = "$rootProject.projectDir/intellij/testOut" as File
  11. whenConfigured { module ->
  12. def allClasses = module.dependencies.findAll() { dep ->
  13. if (dep instanceof org.gradle.plugins.ide.idea.model.ModuleLibrary
  14. && dep.classes.find { path ->
  15. path.url.matches('.*jcl-over-slf4j.*') ||
  16. path.url.matches('.*servlet-api.*') ||
  17. path.url.matches('.*jsp-api.*')
  18. }) {
  19. dep.scope = 'COMPILE'
  20. dep.exported = false
  21. }
  22. }
  23. }
  24. }
  25. // GRADLE-1116
  26. eclipseClasspath.whenConfigured { classpath ->
  27. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  28. }
  29. eclipseClasspath.doFirst {
  30. eclipseClasspath.whenConfigured { classpath ->
  31. def includeDeps = project.configurations.getByName('runtime')?.collect { f-> f.absolutePath } as Set
  32. classpath.entries.each { cp ->
  33. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  34. def include = includeDeps.contains(cp.path)
  35. def attr = 'org.eclipse.jst.component.dependency'
  36. if(include && project.hasProperty('war')) {
  37. // GRADLE-1426 (part a)
  38. cp.entryAttributes.put(attr,'/WEB-INF/lib')
  39. } else if(!include) {
  40. // GRADLE-1422
  41. cp.entryAttributes.remove(attr)
  42. }
  43. }
  44. }
  45. }
  46. }
  47. // GRADLE-1426 (part b)
  48. project.plugins.withType(org.gradle.api.plugins.WarPlugin.class).all {
  49. eclipseWtpComponent.whenConfigured { wtpComp ->
  50. wtpComp.wbModuleEntries.findAll { it instanceof org.gradle.plugins.ide.eclipse.model.WbDependentModule }.each { e ->
  51. if(!e.handle.startsWith('module:/resource/')) {
  52. wtpComp.wbModuleEntries.remove(e)
  53. }
  54. }
  55. }
  56. }
  57. tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
  58. whenConfigured { wtpComponent ->
  59. wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
  60. }
  61. }
  62. }
  63. ideaModule {
  64. excludeDirs += file('.gradle')
  65. excludeDirs += file('buildSrc/build')
  66. excludeDirs += file('buildSrc/.gradle')
  67. }
  68. ideaProject {
  69. javaVersion = '1.6'
  70. subprojects = [rootProject] + javaProjects
  71. withXml { provider ->
  72. // Use git
  73. def node = provider.asNode()
  74. def vcsConfig = node.component.find { it.'@name' == 'VcsDirectoryMappings' }
  75. vcsConfig.mapping[0].'@vcs' = 'Git'
  76. }
  77. }