ide-integration.gradle 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import org.gradle.plugins.ide.eclipse.model.SourceFolder
  2. configure(allprojects) {
  3. apply plugin: 'idea'
  4. apply plugin: 'eclipse'
  5. eclipse.project.name = "${project.name}-3.2.x"
  6. }
  7. configure(javaProjects) {
  8. eclipse.classpath.downloadSources = true
  9. // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
  10. eclipse.classpath {
  11. defaultOutputDir = file('bin/main')
  12. file.whenMerged { cp ->
  13. cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
  14. }
  15. }
  16. // GRADLE-1422
  17. project.eclipseClasspath.doFirst {
  18. // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
  19. project.eclipse.classpath.file.whenMerged { classpath ->
  20. def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set
  21. classpath.entries.each { cp ->
  22. if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
  23. def include = includeDeps.contains(cp.path)
  24. def attr = 'org.eclipse.jst.component.dependency'
  25. if(!include) {
  26. cp.entryAttributes.remove(attr)
  27. }
  28. }
  29. }
  30. }
  31. }
  32. tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
  33. project.eclipse.classpath.file.whenMerged { classpath->
  34. project.eclipse.wtp.component.file.whenMerged { wtpComponent ->
  35. def context = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
  36. if(context) {
  37. wtpComponent.contextPath = context
  38. }
  39. }
  40. }
  41. }
  42. }