11import org.gradle.plugins.ide.eclipse.model.ProjectDependency
2+ import org.gradle.plugins.ide.eclipse.model.SourceFolder
23
4+
5+ apply plugin : " propdeps-eclipse"
6+ apply plugin : " propdeps-idea"
7+
8+ // Replace classpath entries with project dependencies (GRADLE-1116)
39eclipse. classpath. file. whenMerged { classpath ->
4- // GRADLE-1116
510 def regexp = / .*?\/ ([^\/ ]+)\/ build\/ [^\/ ]+\/ (?:main|test)/ // only match those that end in main or test (avoids removing necessary entries like build/classes/jaxb)
611 def projectOutputDependencies = classpath. entries. findAll { entry -> entry. path =~ regexp }
712 projectOutputDependencies. each { entry ->
@@ -19,3 +24,46 @@ eclipse.classpath.file.whenMerged { classpath ->
1924 }
2025 classpath. entries. removeAll { entry -> (entry. path =~ / (?!.*?repack.*\. jar).*?\/ ([^\/ ]+)\/ build\/ libs\/ [^\/ ]+\. jar/ ) }
2126}
27+
28+
29+ // Use separate main/test outputs (prevents WTP from packaging test classes)
30+ eclipse. classpath. defaultOutputDir = file(project. name+ " /eclipse/bin" )
31+ eclipse. classpath. file. whenMerged { classpath ->
32+ classpath. entries. findAll{ it instanceof SourceFolder }. each {
33+ it. output = " build/eclipse/" + it. path. split(" /" )[1 ]
34+ }
35+ }
36+
37+ // Allow projects to be used as WPT modules
38+ eclipse. project. natures " org.eclipse.wst.common.project.facet.core.nature"
39+
40+
41+ // Include project specific settings
42+ task eclipseSettings (type : Copy ) {
43+ from rootProject. files(
44+ " src/eclipse/org.eclipse.jdt.ui.prefs" ,
45+ " src/eclipse/org.eclipse.wst.common.project.facet.core.xml" )
46+ into project. file(' .settings/' )
47+ }
48+
49+ task eclipseWstComponent (type : Copy ) {
50+ from rootProject. files(
51+ " src/eclipse/org.eclipse.wst.common.component" )
52+ into project. file(' .settings/' )
53+ expand(deployname : project. name)
54+ }
55+
56+ task eclipseJdtPrepare (type : Copy ) {
57+ from rootProject. file(" src/eclipse/org.eclipse.jdt.core.prefs" )
58+ into project. file(" .settings/" )
59+ }
60+
61+ task cleanEclipseJdtUi (type : Delete ) {
62+ delete project. file(" .settings/org.eclipse.jdt.ui.prefs" );
63+ delete project. file(" .settings/org.eclipse.wst.common.component" );
64+ delete project. file(" .settings/org.eclipse.wst.common.project.facet.core.xml" );
65+ }
66+
67+ tasks[" eclipseJdt" ]. dependsOn(eclipseJdtPrepare)
68+ tasks[" cleanEclipse" ]. dependsOn(cleanEclipseJdtUi)
69+ tasks[" eclipse" ]. dependsOn(eclipseSettings, eclipseWstComponent)
0 commit comments