Reviewers: rchandia,

Description:
Modifying WebAppCreator to include jars from the war/WEB-INF/lib folder
on the Eclipse classpath when generating an Eclipse project view the ant
build target "eclipse.generate". Currently, if the user adds jars to
WEB-INF/lib (such as the DynaTableRf sample), then generates an Eclipse
project, those jars are not on the classpath, which causes Eclipse
compile errors.  With this change, they will be on the classpath.  This
puts gwt-servlet.jar on the classpath as well, but that seems like the
desired behavior now that gwt-servlet.jar includes external jars which
are not contained in gwt-user.jar.

Issue: 5362


Please review this at http://gwt-code-reviews.appspot.com/976802/show

Affected files:
  M user/src/com/google/gwt/user/tools/.classpathsrc
  M user/src/com/google/gwt/user/tools/WebAppCreator.java


Index: user/src/com/google/gwt/user/tools/.classpathsrc
===================================================================
--- user/src/com/google/gwt/user/tools/.classpathsrc    (revision 9027)
+++ user/src/com/google/gwt/user/tools/.classpathsrc    (working copy)
@@ -6,4 +6,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
    <classpathentry kind="output" path="@warFolder/WEB-INF/classes"/>
+...@serverclasspathlibs
 </classpath>
Index: user/src/com/google/gwt/user/tools/WebAppCreator.java
===================================================================
--- user/src/com/google/gwt/user/tools/WebAppCreator.java       (revision 9027)
+++ user/src/com/google/gwt/user/tools/WebAppCreator.java       (working copy)
@@ -337,6 +337,7 @@
     File srcDir = Utility.getDirectory(outDir, srcFolder, true);
     File warDir = Utility.getDirectory(outDir, warFolder, true);
     File webInfDir = Utility.getDirectory(warDir, "WEB-INF", true);
+    File libDir = Utility.getDirectory(webInfDir, "lib", true);
File moduleDir = Utility.getDirectory(srcDir, modulePackageName.replace(
         '.', '/'), true);
     File clientDir = Utility.getDirectory(moduleDir, "client", true);
@@ -368,6 +369,19 @@
     replacements.put("@testFolder", testFolder);
     replacements.put("@warFolder", warFolder);

+    // Collect the list of server libs to include on the eclipse classpath.
+    StringBuilder serverLibs = new StringBuilder();
+    if (libDir.exists()) {
+      for (File file : libDir.listFiles()) {
+        if (file.getName().toLowerCase().endsWith(".jar")) {
+ serverLibs.append(" <classpathentry kind=\"lib\" path=\"war/WEB-INF/lib/");
+          serverLibs.append(file.getName());
+          serverLibs.append("\"/>\n");
+        }
+      }
+    }
+    replacements.put("@serverClasspathLibs", serverLibs.toString());
+
     String antEclipseRule = "";
     if (noEclipse) {
       /*


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to