Reroll of r9908 (rolled back at r9911): Fixes issue 6189. WebAppCreator was not scanning war/WEB-INF/lib to fill up .classpath Added support for windows path separator to testCreatorOnlyEclipseWithJars() Review at http://gwt-code-reviews.appspot.com/1399801 Review by: jlabanca@google.com git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9919 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/tools/WebAppCreator.java b/user/src/com/google/gwt/user/tools/WebAppCreator.java index 8ddefe8..c3be99c 100644 --- a/user/src/com/google/gwt/user/tools/WebAppCreator.java +++ b/user/src/com/google/gwt/user/tools/WebAppCreator.java
@@ -542,7 +542,7 @@ replacements.put("@copyServletDeps", copyServletDeps); // Collect the list of server libs to include on the eclipse classpath. - File libDirectory = new File(outDir + warFolder + "WEB-INF/lib"); + File libDirectory = new File(outDir + "/" + warFolder + "/WEB-INF/lib"); StringBuilder serverLibs = new StringBuilder(); if (libDirectory.exists()) { for (File file : libDirectory.listFiles()) {
diff --git a/user/test/com/google/gwt/user/tools/WebAppCreatorTest.java b/user/test/com/google/gwt/user/tools/WebAppCreatorTest.java index 60fcc91..7d97f95 100644 --- a/user/test/com/google/gwt/user/tools/WebAppCreatorTest.java +++ b/user/test/com/google/gwt/user/tools/WebAppCreatorTest.java
@@ -15,12 +15,14 @@ */ package com.google.gwt.user.tools; +import com.google.gwt.dev.util.Util; import com.google.gwt.user.tools.WebAppCreator.ArgProcessor; import junit.framework.TestCase; import java.io.File; import java.io.IOException; +import java.util.regex.Pattern; /** * Test Class for WebAppCreator. @@ -265,6 +267,34 @@ } /** + * Generate a .classpath containing a .jar in war/WEB-INF/lib + */ + public void testCreatorOnlyEclipseWithJars() throws IOException, WebAppCreatorException { + runCreator("-out", projectFolder, "-XnoEclipse", "-junit", mockJar, + MY_PROJECT); + + String libDir = "war" + File.separatorChar + + "WEB-INF" + File.separatorChar + + "lib"; + assertTrue(new File(projectFolder + File.separatorChar + libDir).mkdirs()); + + String libJarName = libDir + File.separatorChar + "foo.jar"; + File libFile = new File(projectFolder + File.separatorChar + libJarName); + assertTrue(libFile.createNewFile()); + + runCreator("-out", projectFolder, "-XonlyEclipse", "-junit", mockJar, + MY_PROJECT); + + assertFileExists(".classpath"); + File classpathFile = new File(projectFolder + File.separatorChar + ".classpath"); + String classpathContents = Util.readURLAsString(classpathFile.toURI().toURL()); + String canonicalLibJarName = libJarName.replaceAll(Pattern.quote(File.separator), "/"); + assertTrue(".classpath does not contain " + canonicalLibJarName + ". .classpath contents:" + + classpathContents, + classpathContents.contains(canonicalLibJarName)); + } + + /** * Test the main method. */ public void testMain() {