views:

470

answers:

2

Hello all,

I am trying to run an ant build script that compiles GWT. This script includes a large number of libraries, each with a relatively long path. My GWT code only touches some of these libraries; however, it is convenient to include all of the libaries from the lib directory that I use for this and all of the other applications I am developing. Here is the relevant portion of my build script:

<path id="gwt.project.class.path">
  <pathelement location="gen"/>
  <pathelement location="${gwt.sdk}/gwt-user.jar"/>
  <fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
  <fileset dir="${smartgwt.sdk}" includes="smartgwt*.jar"/>
  <!-- Add any additional non-server libs (such as JUnit) -->
  <fileset dir="lib" includes="**/*.jar"/>
</path>

<target name="gwtc" depends="compileApp" description="GWT compile to JavaScript" unless="noGWTModule">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
  <classpath>
    <pathelement location="src"/>
    <path refid="gwt.project.class.path"/>
  </classpath>
  <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
  <jvmarg value="-Xmx256M"/>
  <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
  <arg value="${gwt.module}"/>
  <arg value="-war" />
  <arg value="${gwt.gen.dir}" />
</java>
</target>`

When I try to run this, I get the following error:

java.io.IOException: CreateProcess: "C:\Program Files\Java\jdk1.5.0_11\jre\bin\java.exe" -Xmx256M -classpath "C:\Program Files\Common Files\eclipse\workspace\development\src;C:\Program Files\Common Files\eclipse\workspace\development\lib\build\hbBuildSupport.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\ehcache.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\hibernate-annotations.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\hibernate-commons-annotations.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\hibernate-entitymanager.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\hibernate-tools.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\hibernate-validator.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\hibernate3.jar;C:\Program Files\Common Files\eclipse\workspace\development\lib\db\hibernate\javassi�

It seems that at somepoint of the compilation, the string containing all of the library paths are getting truncated. Could this be due to some character limit on CreateProcess? This CreateProcess command string gets to be only about 1024 characters long before truncation, which seems like a small limit. Is there anyway to increase this limit? Any thoughts/solutions/workarounds appreciated.

Thanks, Mayur

A: 

One possible workaround for a very long classpath is to use the java.ext.dirs property and to drop all you compile-time dependencies (the JAR-files that are now referenced in your classpath) in this directory.

pmf
+1  A: 

The problem is that Windows command lines are limited 8191 characters and GWT is putting the full path to each jar in the classpath. The only way to fix this is to move the jars to a directory with a shorter path.

You can do this under windows by making a symbolic link and then referencing that link in your build file. Something like this

From the root of c:

mklink /D jars C:\Program Files\Common Files\eclipse\workspace\development\lib

Wikpedia entry on windows symbolic links

Jon Strayer