I just did a simple batch:
@echo off
echo [batch]
exit /b 2
And your ant script from above, and exec returned with the error code from my batch. Everything worked fine.
exec returned: 2
This was tested on:
Apache Ant(TM) version 1.9.3 compiled on December 23 2013
on Windows 7 64-bit
You should paste your batch file and the actual result you get from running your ant. Either there is something wrong with the version of Ant you are using, or (most likely) something wrong with the batch file.
Do the following
- Run the
sbt.bat publish
from the command line - Immediately after that run
echo %ERRORLEVEL%
and note the result
If you are getting 0
, your batch is the problem.
Edit: Alternatively, there is an article here that describes a workaround with a macrodef