diff -uNr ./src/main/groovy/org/gradle/api/plugins/JavaPlugin.java ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/plugins/JavaPlugin.java
--- ./src/main/groovy/org/gradle/api/plugins/JavaPlugin.java	2008-09-15 16:22:26.000000000 +0100
+++ ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/plugins/JavaPlugin.java	2008-10-01 14:13:47.000000000 +0100
@@ -33,6 +33,7 @@
 import org.gradle.api.tasks.ide.eclipse.EclipseClean;
 import org.gradle.api.tasks.ide.eclipse.EclipseProject;
 import org.gradle.api.tasks.ide.eclipse.ProjectType;
+import org.gradle.api.tasks.ide.eclipse.EclipseWtpModule;
 import org.gradle.api.tasks.javadoc.Javadoc;
 import org.gradle.api.tasks.testing.Test;
 import org.gradle.api.tasks.testing.ForkMode;
@@ -69,6 +70,7 @@
     public static final String ECLIPSE_CLEAN = "eclipseClean";
     public static final String ECLIPSE_PROJECT = "eclipseProject";
     public static final String ECLIPSE_CP = "eclipseCp";
+    public static final String ECLIPSE_WTP_MODULE = "eclipseWtpModule";
 
     public void apply(Project project, PluginRegistry pluginRegistry) {
         apply(project, pluginRegistry, new HashMap());
@@ -114,7 +116,7 @@
         distsUpload.getConfigurations().add(DISTS);
 
         configureEclipse(project);
-
+	 configureEclipseWtpModule(project);
     }
 
     private void configureEclipse(Project project) {
@@ -128,10 +130,22 @@
     private EclipseProject configureEclipseProject(Project project) {
         EclipseProject eclipseProject = (EclipseProject) project.createTask(GUtil.map("type", EclipseProject.class), ECLIPSE_PROJECT);
         eclipseProject.setProjectName(project.getName());
-        eclipseProject.setProjectType(ProjectType.JAVA);
+	 eclipseProject.setProjectType(ProjectType.JAVA);
         return eclipseProject;
     }
 
+    private void configureEclipseWtpModule(Project project) {
+	EclipseWtpModule eclipseWtpModule = (EclipseWtpModule) project.createTask(GUtil.map("type", EclipseWtpModule.class), ECLIPSE_WTP_MODULE);
+
+
+	eclipseWtpModule.conventionMapping(GUtil.map(
+                "srcDirs", new ConventionValue() {
+            public Object getValue(Convention convention, Task task) {
+                return GUtil.addLists(java(convention).getSrcDirs(), java(convention).getResourceDirs());
+            }
+        }));
+    }
+
     private EclipseClasspath configureEclipseClasspath(Project project) {
         EclipseClasspath eclipseClasspath = (EclipseClasspath) project.createTask(GUtil.map("type", EclipseClasspath.class), ECLIPSE_CP);
         eclipseClasspath.conventionMapping(GUtil.map(
diff -uNr ./src/main/groovy/org/gradle/api/plugins/WarPlugin.java ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/plugins/WarPlugin.java
--- ./src/main/groovy/org/gradle/api/plugins/WarPlugin.java	2008-08-28 11:47:26.000000000 +0100
+++ ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/plugins/WarPlugin.java	2008-09-30 17:41:13.000000000 +0100
@@ -22,6 +22,8 @@
 import org.gradle.api.Project;
 import org.gradle.api.Task;
 import org.gradle.api.dependencies.Filter;
+import org.gradle.api.dependencies.ProjectDependency;
+import org.gradle.api.dependencies.Dependency;
 import org.gradle.api.internal.project.PluginRegistry;
 import org.gradle.api.tasks.ConventionValue;
 import org.gradle.api.tasks.bundling.Bundle;
@@ -105,6 +107,13 @@
                 return task.getProject().getDependencies().getDependencies(Filter.PROJECTS_ONLY);
             }
         }));
+
+
+	//we depend of the execution of the eclipse task on our dependent projects
+	for (Dependency dependentProject : project.getDependencies().getDependencies(Filter.PROJECTS_ONLY)) {
+		eclipseWtp.dependsOn(":" + ((ProjectDependency) dependentProject).getProject().getName() + ":eclipseProject");
+	}
+
         return eclipseWtp;
     }
 
diff -uNr ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseProjectFile.java ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseProjectFile.java
--- ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseProjectFile.java	1970-01-01 01:00:00.000000000 +0100
+++ ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseProjectFile.java	2008-10-01 11:25:02.000000000 +0100
@@ -0,0 +1 @@
+
diff -uNr ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseUtil.java ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseUtil.java
--- ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseUtil.java	2008-08-28 16:40:26.000000000 +0100
+++ ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseUtil.java	2008-10-07 10:26:43.000000000 +0100
@@ -19,6 +19,16 @@
 import org.gradle.api.dependencies.ProjectDependency;
 import org.apache.commons.io.FilenameUtils;
 
+import org.dom4j.Document;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.dom4j.io.SAXReader;
+import org.dom4j.tree.DefaultText;
+import org.dom4j.Attribute;
+import org.dom4j.tree.DefaultAttribute;
+
 import java.util.*;
 
 /**
@@ -45,4 +55,20 @@
     static String relativePath(Project project, Object path) {
         return FilenameUtils.separatorsToUnix(project.relativePath(path).toString());
     }
+
+    static void addFacet(Document document, String facetType, Attribute... attributes)
+    {
+	Element root;
+	if(document.getRootElement() == null || (root = ((Element) document.selectSingleNode("//faceted-project"))) == null)
+	{
+		root = 	document.addElement("faceted-project");
+	}
+
+	Element facet = root.addElement(facetType);
+
+	for(Attribute attribute : attributes)
+	{
+		facet.add(attribute);
+	}
+    }
 }
diff -uNr ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtp.java ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtp.java
--- ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtp.java	2008-08-28 16:40:26.000000000 +0100
+++ ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtp.java	2008-10-01 15:28:26.000000000 +0100
@@ -21,6 +21,11 @@
 import org.dom4j.Element;
 import org.dom4j.io.OutputFormat;
 import org.dom4j.io.XMLWriter;
+import org.dom4j.io.SAXReader;
+import org.dom4j.tree.DefaultText;
+import org.dom4j.Attribute;
+import org.dom4j.tree.DefaultAttribute;
+
 import org.gradle.api.GradleException;
 import org.gradle.api.Project;
 import org.gradle.api.Task;
@@ -60,6 +65,7 @@
 
     public EclipseWtp(Project project, String name, Dag tasksGraph) {
         super(project, name, tasksGraph);
+
         doFirst(new TaskAction() {
             public void execute(Task task, Dag tasksGraph) {
                 generateWtp();
@@ -79,12 +85,40 @@
             XMLWriter writer = new XMLWriter(new FileWriter(wtpFile), OutputFormat.createPrettyPrint());
             writer.write(createXmlDocument());
             writer.close();
-
+		
+	    createFacets(getProject());
         } catch (IOException e) {
             throw new GradleException("Problem when writing Eclipse project file.", e);
         }
     }
 
+    private void createFacets(Project project)
+    {
+        Document document = DocumentFactory.getInstance().createDocument();
+
+	EclipseUtil.addFacet(document, "fixed", new DefaultAttribute("facet", "jst.java"));
+	EclipseUtil.addFacet(document, "fixed", new DefaultAttribute("facet", "jst.web"));
+
+	EclipseUtil.addFacet(document, "installed", new DefaultAttribute("facet", "jst.java"), new DefaultAttribute("version", "5.0"));
+	EclipseUtil.addFacet(document, "installed", new DefaultAttribute("facet", "jst.web"), new DefaultAttribute("version", "2.4"));
+
+	try {
+		File facetFile = project.file(".settings/org.eclipse.wst.common.project.facet.core.xml");
+		if(facetFile.exists())
+		{
+			facetFile.delete();
+		}
+		if(!facetFile.getParentFile().exists()) {
+                 	facetFile.getParentFile().mkdirs();
+                }
+		XMLWriter writer = new XMLWriter(new FileWriter(facetFile), OutputFormat.createPrettyPrint());
+		writer.write(document);
+		writer.close();
+	} catch (IOException e) {
+            throw new GradleException("Problem when writing Eclipse project file.", e);
+        }
+    }
+
     private Document createXmlDocument() {
         Document document = DocumentFactory.getInstance().createDocument();
         Element root = document.addElement("project-modules").addAttribute("id", "moduleCoreId").addAttribute("project-version", "1.5.0");
@@ -111,7 +145,7 @@
         for (String libPath : EclipseUtil.getSortedStringList(getWarLibs())) {
             wbModule.addElement("dependent-module").
                     addAttribute("deploy-path", "/WEB-INF/lib").
-                    addAttribute("handle", "module:/classpath/" + FilenameUtils.separatorsToUnix(libPath)).
+                    addAttribute("handle", "module:/classpath/lib//" + FilenameUtils.separatorsToUnix(libPath)).
                     addElement("dependency-type").setText("uses");
         }
     }
@@ -120,7 +154,7 @@
         for (Project project : EclipseUtil.getDependsOnProjects(getProjectDependencies())) {
             wbModule.addElement("dependent-module").
                     addAttribute("deploy-path", "/WEB-INF/lib").
-                    addAttribute("handle", "module:/resource/" + project.getName()).
+                    addAttribute("handle", "module:/resource/" + project.getName() + "/" + project.getName()).
                     addElement("dependency-type").setText("uses");
         }
     }
diff -uNr ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtpModule.java ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtpModule.java
--- ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtpModule.java	1970-01-01 01:00:00.000000000 +0100
+++ ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/EclipseWtpModule.java	2008-10-01 15:42:36.000000000 +0100
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2007-2008 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.gradle.api.tasks.ide.eclipse;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentFactory;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.dom4j.io.SAXReader;
+import org.dom4j.tree.DefaultText;
+import org.dom4j.tree.DefaultAttribute;
+import org.gradle.api.GradleException;
+import org.gradle.api.Project;
+import org.gradle.api.Task;
+import org.gradle.api.TaskAction;
+import org.gradle.api.dependencies.ProjectDependency;
+import org.gradle.api.internal.ConventionTask;
+import org.gradle.execution.Dag;
+import org.apache.commons.io.FilenameUtils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Generates Eclipse configuration files for Eclipse WTP modules
+ * 
+ * @author Phil Messenger
+ */
+public class EclipseWtpModule extends ConventionTask {
+
+    private List<Object> srcDirs;
+
+    public EclipseWtpModule(Project project, String name, Dag tasksGraph) {
+        super(project, name, tasksGraph);
+
+        doFirst(new TaskAction() {
+            public void execute(Task task, Dag tasksGraph) {
+                generateWtpModule();
+            }
+        });
+    }
+
+    private void generateWtpModule()
+    {
+        File wtpFile = getProject().file(EclipseWtp.WTP_FILE_DIR + "/" + EclipseWtp.WTP_FILE_NAME);
+        if (wtpFile.exists()) {
+            wtpFile.delete();
+        }
+        if (!wtpFile.getParentFile().exists()) {
+            wtpFile.getParentFile().mkdirs();
+        }
+        try {
+            XMLWriter writer = new XMLWriter(new FileWriter(wtpFile), OutputFormat.createPrettyPrint());
+            writer.write(createXmlDocument());
+            writer.close();
+		
+	    createFacets(getProject());
+        } catch (IOException e) {
+            throw new GradleException("Problem when writing Eclipse project file.", e);
+        }
+    }
+
+    private void createFacets(Project project)
+    {
+        Document document = DocumentFactory.getInstance().createDocument();
+
+	EclipseUtil.addFacet(document, "fixed", new DefaultAttribute("facet", "jst.java"));
+	EclipseUtil.addFacet(document, "fixed", new DefaultAttribute("facet", "jst.utility"));
+
+	EclipseUtil.addFacet(document, "installed", new DefaultAttribute("facet", "jst.java"), new DefaultAttribute("version", "5.0"));
+	EclipseUtil.addFacet(document, "installed", new DefaultAttribute("facet", "jst.utility"), new DefaultAttribute("version", "1.0"));
+
+	try {
+		File facetFile = project.file(".settings/org.eclipse.wst.common.project.facet.core.xml");
+		if(facetFile.exists())
+		{
+			facetFile.delete();
+		}
+		if(!facetFile.getParentFile().exists()) {
+                 	facetFile.getParentFile().mkdirs();
+                }
+		XMLWriter writer = new XMLWriter(new FileWriter(facetFile), OutputFormat.createPrettyPrint());
+		writer.write(document);
+		writer.close();
+	} catch (IOException e) {
+            throw new GradleException("Problem when writing Eclipse project file.", e);
+        }
+    }
+
+    private Document createXmlDocument() {
+        Document document = DocumentFactory.getInstance().createDocument();
+        Element root = document.addElement("project-modules").addAttribute("id", "moduleCoreId").addAttribute("project-version", "1.5.0");
+        Element wbModule = root.addElement("wb-module").addAttribute("deploy-name", getProject().getName());
+        addResourceMappings(wbModule);
+        return document;
+    }
+
+    private void addResourceMappings(Element wbModule) {
+        for(Object srcDir : getSrcDirs())
+	{
+		wbModule.addElement("wb-resource").addAttribute("deploy-path", "/").addAttribute("source-path", EclipseUtil.relativePath(getProject(), srcDir.toString()));
+	}
+    }	
+
+    public void setSrcDirs(List<Object> srcDirs) {
+        this.srcDirs = srcDirs;
+    }
+
+    public List<Object> getSrcDirs() {
+        return (List<Object>) conv(srcDirs, "srcDirs");
+    }
+}
diff -uNr ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/ProjectType.java ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/ProjectType.java
--- ./src/main/groovy/org/gradle/api/tasks/ide/eclipse/ProjectType.java	2008-08-28 11:47:26.000000000 +0100
+++ ../gradle-0.4-src.phil/src/main/groovy/org/gradle/api/tasks/ide/eclipse/ProjectType.java	2008-10-01 15:02:07.000000000 +0100
@@ -20,9 +20,25 @@
         public List<String> natureNames() {
             return new ArrayList<String>();
         }
+    },
+    WTP_MODULE {
+	public List<String> buildCommandNames() {
+	    return WrapUtil.toList("org.eclipse.jdt.core.javabuilder", "org.eclipse.wst.common.project.facet.core.builder", "org.eclipse.wst.validation.validationbuilder");
+        }
+        public List<String> natureNames() {
+            return WrapUtil.toList("org.eclipse.jdt.core.javanature", "org.eclipse.wst.common.project.facet.core.nature", "org.eclipse.wst.common.modulecore.ModuleCoreNature");
+        }
+    },
+    WTP_WEBAPP {
+	public List<String> buildCommandNames() {
+	    return WrapUtil.toList("org.eclipse.jdt.core.javabuilder", "org.eclipse.wst.common.project.facet.core.builder", "org.eclipse.wst.validation.validationbuilder");
+        }
+        public List<String> natureNames() {
+            return WrapUtil.toList("org.eclipse.jdt.core.javanature", "org.eclipse.wst.common.project.facet.core.nature", "org.eclipse.wst.common.modulecore.ModuleCoreNature");
+        }
     };
 
     public abstract List<String> buildCommandNames();
 
     public abstract List<String> natureNames();
-}
\ No newline at end of file
+}
diff -uNr ./src/test/resources/org/gradle/api/tasks/ide/eclipse/expectedWtpFile.txt ../gradle-0.4-src.phil/src/test/resources/org/gradle/api/tasks/ide/eclipse/expectedWtpFile.txt
--- ./src/test/resources/org/gradle/api/tasks/ide/eclipse/expectedWtpFile.txt	2008-08-28 16:40:22.000000000 +0100
+++ ../gradle-0.4-src.phil/src/test/resources/org/gradle/api/tasks/ide/eclipse/expectedWtpFile.txt	2008-09-30 12:11:45.000000000 +0100
@@ -6,13 +6,13 @@
     <wb-resource deploy-path="WEB-INF/lib" source-path="conf1"/>
     <wb-resource deploy-path="WEB-INF/lib" source-path="conf2/child"/>
     <property name="java-output-path" value="bin"/>
-    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/a.jar">
+    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib//lib/a.jar">
       <dependency-type>uses</dependency-type>
     </dependent-module>
-    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/b.jar">
+    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib//lib/b.jar">
       <dependency-type>uses</dependency-type>
     </dependent-module>
-    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/dependent">
+    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/dependent/dependent">
       <dependency-type>uses</dependency-type>
     </dependent-module>
   </wb-module>
