ide.gradle 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import org.gradle.plugins.ide.eclipse.model.SourceFolder
  2. apply plugin: 'eclipse-wtp'
  3. apply plugin: 'propdeps-idea'
  4. apply plugin: 'propdeps-eclipse'
  5. eclipse.classpath.downloadSources = true
  6. eclipse.project.buildCommand "net.sf.eclipsecs.core.CheckstyleBuilder"
  7. eclipse.project.natures "net.sf.eclipsecs.core.CheckstyleNature"
  8. // Include project specific settings
  9. task eclipseCheckstyle(type: Copy) {
  10. from rootProject.files(
  11. "etc/eclipse/.checkstyle")
  12. into project.projectDir
  13. expand(configDir: rootProject.file('config/checkstyle').absolutePath)
  14. }
  15. task eclipseSettings(type: Copy) {
  16. from rootProject.files(
  17. "etc/eclipse/org.eclipse.jdt.ui.prefs",
  18. "etc/eclipse/org.eclipse.wst.common.project.facet.core.xml")
  19. into project.file('.settings/')
  20. outputs.upToDateWhen { false }
  21. }
  22. task eclipseWstComponent(type: Copy) {
  23. from rootProject.files(
  24. "etc/eclipse/org.eclipse.wst.common.component")
  25. into project.file('.settings/')
  26. expand(deployname: project.name)
  27. outputs.upToDateWhen { false }
  28. }
  29. task eclipseJdtPrepare(type: Copy) {
  30. from rootProject.file("etc/eclipse/org.eclipse.jdt.core.prefs")
  31. into project.file(".settings/")
  32. outputs.upToDateWhen { false }
  33. }
  34. task cleanEclipseJdtUi(type: Delete) {
  35. delete project.file(".settings/org.eclipse.jdt.core.prefs")
  36. delete project.file(".settings/org.eclipse.jdt.ui.prefs")
  37. delete project.file(".settings/org.eclipse.wst.common.component")
  38. delete project.file(".settings/org.eclipse.wst.common.project.facet.core.xml")
  39. }
  40. tasks["eclipseJdt"].dependsOn(eclipseJdtPrepare)
  41. tasks["cleanEclipse"].dependsOn(cleanEclipseJdtUi)
  42. tasks["eclipse"].dependsOn(eclipseCheckstyle, eclipseSettings, eclipseWstComponent)
  43. eclipse {
  44. classpath {
  45. plusConfigurations += [ configurations.integrationTestCompile ]
  46. }
  47. }
  48. // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
  49. eclipse.classpath {
  50. defaultOutputDir = file('bin/main')
  51. file.whenMerged { cp ->
  52. cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
  53. }
  54. }
  55. // GRADLE-1116
  56. project.eclipse.classpath.file.whenMerged { classpath ->
  57. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/test') }
  58. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
  59. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/resources/main') }
  60. classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/main') }
  61. }
  62. // GRADLE-1422
  63. project.eclipseClasspath.doFirst {
  64. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  65. project.eclipse.classpath.file.whenMerged { classpath ->
  66. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  67. classpath.entries.each { cp ->
  68. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  69. def include = includeDeps.contains(cp.path)
  70. def attr = 'org.eclipse.jst.component.dependency'
  71. if(!include) {
  72. cp.entryAttributes.remove(attr)
  73. }
  74. }
  75. }
  76. }
  77. }
  78. project.idea.module {
  79. scopes.TEST.plus += [project.configurations.integrationTestRuntime]
  80. testSourceDirs += sourceSets.integrationTest.resources.srcDirs
  81. }