Task throws error=7: Argument list too long
With a command that long you are likely running in to ARG_MAX at the shell.
This will report a good estimate of the available length, expr
getconf ARG_MAX
- env|wc -c
- env|wc -l
* 4 - 2048
A nice article about command arg lists and length can be found here
Run ant -d
. This will produce capacious amounts of output. However, it will also show your entire compile line which may help you understand why it is so long.
Are you using Jenkins/Hudson and that's where the error occurs?
Try the following:
- Disable the build.
- Log into your build server, AS YOUR JENKINS USER and find the
workdir
directory where Jenkins/Hudson is attempting the build. - You may have to change
$PATH
or set$JAVA_HOME
to point to the JDK that Hudson/Jenkins is using. - Now, run
ant -d
<target>
just as Jenkins/Hudson would. Pipe this output throughtee
into a file. Now, take a look and see what Hudson/Jenkins is doing and whyjavac
has too many arguments.
Use apply
for your fileset
in your build.xml
, e.g.
<?xml version="1.0" encoding="UTF-8"?><project default="build"> <fileset id="myfiles" dir="${basedir}"> <include name="**/*.java"/> <exclude name="**/Resources/**"/> <modified> <param name="cache.cachefile" value="${basedir}/cache.${project}.fileset.myfiles.properties"/> </modified> </fileset> <target name="execute-some-command"> <apply executable="javac" dir="${basedir}" failonerror="true"> <fileset refid="myfiles"/> </apply> </target></project>
By default, the command will be executed once for every file.
If you need to use parallel
to run the command only once, then use maxparallel
to limit the amount of parallelism by passing at most this many sourcefiles at once (e.g. set to 1000
to pass a thousand files per run). For example:
<apply executable="javac" parallel="true" maxparallel="1000" dir="${basedir}"> <fileset refid="myfiles"/></apply>
To see how many files you've got in total, check the content of cache file (look for cache.cachefile
in above example).