https://bz.apache.org/bugzilla/show_bug.cgi?id=57888

            Bug ID: 57888
           Summary: exec task mangles command-line arguments ending in
                    equals sign
           Product: Ant
           Version: 1.9.4
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
          Assignee: [email protected]
          Reporter: [email protected]

build.xml:

    <project name="test" default="build">
      <target name="build">
        <exec executable="cmd.exe" failonerror="true">
          <arg value="/c"/>
          <arg value="ant.bat"/>
          <arg value="-Da="/>
          <arg value="-Db=c"/>
        </exec>
      </target>
    </project>

sub-build.xml:

    <project name="sub-build" default="build">
      <target name="build">
        <echo message="The value we get in the sub-build: ${a}"/>
      </target>
    </project>

C:\Users\Tester\Documents\issues\ant\cmd mangling>ant -verbose
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m;
support was removed in 8.0
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
Trying the default build file: build.xml
Buildfile: C:\Users\Tester\Documents\issues\ant\cmd mangling\build.xml
Detected Java version: 1.8 in: c:\DevEnv\Tools\Java\jdk1.8.0_05\jre
Detected OS: Windows 8
parsing buildfile C:\Users\Tester\Documents\issues\ant\cmd mangling\build.xml
with URI = file:/C:/Users/Tester/Documents/issues/ant/cmd%20mangling/build.xml
Project base dir set to: C:\Users\Tester\Documents\issues\ant\cmd mangling
Build sequence for target(s) `build' is [build]
Complete build sequence is [build, ]

build:
parsing buildfile
jar:file:/C:/DevEnv/Common/Tools/Ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml
with URI =
jar:file:/C:/DevEnv/Common/Tools/Ant/lib/ant.jar!/org/apache/tools/an
t/antlib.xml from a zip file
     [exec] Current OS is Windows 8
     [exec] Executing 'cmd.exe' with arguments:
     [exec] '/c'
     [exec] 'ant.bat'
     [exec] '-Da='
     [exec] '-Db=c'
     [exec]
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
     [exec] Buildfile: C:\Users\Tester\Documents\issues\ant\cmd
mangling\build.xml
     [exec]
     [exec] BUILD FAILED
     [exec] Target "c" does not exist in the project "test".
     [exec]
     [exec] Total time: 0 seconds

Other notes:
* The same happens if you exec executable="ant.bat". This script uses "cmd.exe"
because the exec task docs warn about "ant.bat" not working (which does not
appear to be the case.)
* The equivalent works fine on any other platform.
* Using exec to run java instead seems to work, but then you have to mess
around replicating things handled by the Ant script, such as inserting ANT_OPTS
and ANT_ARGS at the appropriate positions.

The road here:
* We had to run our build under a different JDK from the one Ant was launched
with.
* Since the <ant> task doesn't let you specify the JDK to use at all, we tried
to fork ant explicitly using <exec>.
* Now we find our command-line is being mangled.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to