You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2015/05/05 03:25:07 UTC

[Bug 57888] New: exec task mangles command-line arguments ending in equals sign

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: notifications@ant.apache.org
          Reporter: trejkaz@trypticon.org

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.

[Bug 57888] ant.bat (or cmd?) mangles command-line arguments ending in equals sign

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57888

--- Comment #3 from Trejkaz (pen name) <tr...@trypticon.org> ---
My guess is that providing an ant.exe might get around it.

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

[Bug 57888] ant.bat (or cmd?) mangles command-line arguments ending in equals sign

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57888

Trejkaz (pen name) <tr...@trypticon.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|exec task mangles           |ant.bat (or cmd?) mangles
                   |command-line arguments      |command-line arguments
                   |ending in equals sign       |ending in equals sign
                 OS|                            |All

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

[Bug 57888] ant.bat (or cmd?) mangles command-line arguments ending in equals sign

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57888

--- Comment #2 from Stefan Bodewig <bo...@apache.org> ---
This is the nature of Windows batch files
https://support.microsoft.com/en-us/kb/35938

The code inside the batch file sees

'/c'
'ant.bat'
'-Da'
'-Db'
'c'

and there isn't anything we could do about it.  You will need to provide some
kind of value to a.  IIRC quoting won't help either.

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

[Bug 57888] ant.bat (or cmd?) mangles command-line arguments ending in equals sign

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57888

--- Comment #1 from Trejkaz (pen name) <tr...@trypticon.org> ---
Turns out running it directly breaks too, so I guess it isn't exec, it must be
either cmd or the batch file.

C:\Users\Tester\Documents\issues\ant\cmd mangling> ant -f sub-build.xml -Da=
-Db=c

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m;
support was removed in 8.0
Buildfile: C:\Users\Daniel\Documents\issues\ant\cmd mangling\sub-build.xml

BUILD FAILED
Target "c" does not exist in the project "sub-build".

Total time: 0 seconds

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