I've been fighting in these trenches for a while now and have yet to get this working. Using many examples here on SO as well as others like this blog or this SO post, I still cannot get past the windows classpath limit. I'm currently just dealing with an ant task that runs a single main method in a java class within my source. If I can get this working here, I can extrapolate elsewhere.
First, my original relevant build tasks
<path id="code.classpath">
<path id="code.classpath">
<path refid="jars.code"/>
<path refid="jars.common"/>
<path refid="jars.servlet-api"/>
<dirset dir="${code.dir}" excludes="xlib/scripts/**"/>
</path>
<target name="code.exec" description="Execute a class file">
<echo>${code}</echo>
<input addproperty="code.exec.class">Enter full class name (e.g. ${atmr.pkg}.FooBar):</input>
<input addproperty="code.exec.args">Enter arguments:</input>
<java classname="${code.exec.class}"
fork="true"
dir="${code.src.dir}"
failonerror="true"
classpathref="code.classpath">
<jvmarg value="-Xmx4048M"/>
<jvmarg value="-ea"/>
<jvmarg value="-Dlog4j.configuration=file:${basedir}/log4j.xml"/>
<syspropertyset refid="proxy.properties"/>
<assertions refid="code.exec.assertions"/>
<arg line="${code.exec.args}"/>
</java>
</target>
Next, my most recent attempt at a solution
<path id="code.source">
<dirset dir="${code.dir}" excludes="xlib/scripts/**"/>
</path>
<target name="code.classpath.acme">
<manifestclasspath property="jar.classpath" jarfile="${app.dir}/acme.jar">
<classpath refid="code.source"/>
</manifestclasspath>
<jar destfile="${app.dir}/acme.jar" index="true">
<manifest>
<attribute name="Class-Path" value="${jar.classpath}"/>
</manifest>
</jar>
</target>
<path id="temp.classpath">
<pathelement path="${app.dir}/acme.jar"/>
</path>
<target name="code.exec" description="Execute a class file" >
<property name="myclasspath" refid="temp.classpath"/>
<echo>${code}</echo>
<echo>${basedir}</echo>
<echo>${myclasspath}</echo>
<input addproperty="code.exec.class">Enter full class name (e.g. ${atmr.pkg}.FooBar):</input>
<input addproperty="code.exec.args">Enter arguments:</input>
<java classname="${code.exec.class}"
fork="true"
dir="${code.src.dir}"
failonerror="true"
classpathref="temp.classpath">
<jvmarg value="-Xmx4048M"/>
<jvmarg value="-ea"/>
<jvmarg value="-Dlog4j.configuration=file:${basedir}/log4j.xml"/>
<syspropertyset refid="proxy.properties"/>
<assertions refid="code.exec.assertions"/>
<arg line="${code.exec.args}"/>
</java>
</target>
Basically, when running the first one, I get the "classpath is too long" issue in windows. Running the second one, I get "could not find or load main class package.classname." I've gone through the MANIFEST.MF that is created in the jar and the package location is present. From here went my travels down the rabbit hole to find what could be up. I've tested different permutations of the manifest relative locations to no avail. I've even gone in and manually changed the manifest to an explicit file location (not relative to the jar) with no change in results.
To confirm that the overall code works, I can add my code.dir path into temp.classpath and get the too long error. I can also make the acme jar build with the classes within it and get past the issue with the missing class.
Everywhere I read, this should work. Yet, here I am. I know that if the reference in the manifest can't be found, it silently skips it. That is what it seems to be doing, yet I've tried everything to get it to see what's there to no avail. And thus, I turn to you SO contributors to either point out the silly mistake I've missed, or let me in on the secret knowledge that I have yet to learn.
Thanks in advance.