cancel
Showing results for 
Search instead for 
Did you mean: 

ls.executable doesn't work on windows

bernd_ruecker
Champ in-the-making
Champ in-the-making
Hey guys.

This code in the ant build doesn't work on windows:


  <condition property="ls.executable" value="dir.bat" else="ls">
     <os family="windows"/>
  </condition>

    <exec output="target/libs.engine.txt" executable="${ls.executable}">
      <arg line="${ls.executable.options} ${target.distro.root}/setup/files/libs/engine/runtime"/>
    </exec>

–>

BUILD FAILED
C:\Projekte_Activiti\activiti\qa\build.xml:59: The following error occurred while executing this line:
C:\Projekte_Activiti\activiti\distro\build.xml:105: Execute failed: java.io.IOException: Cannot run program "dir" (in directory "C:\Projekte_Activiti\activiti\distro"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden

It seems that the whole library dependency management get problems if I cannot run this. Can anybody take care of this and get it running in a OS independent manner?

Thanks
Bernd
9 REPLIES 9

tombaeyens
Champ in-the-making
Champ in-the-making
i'm building a new version of library dependency management in the distro.

but i didn't switch yet.  i'm building it next to the existing mvn based setup.  so  the old way should still work.

probably your windows dir thing blocks the build.  can you paste the error?

bernd_ruecker
Champ in-the-making
Champ in-the-making
And a quick addition: As far as I understand this tries to figure out some libraries maybe copied by Maven? The we could as well use the http://maven.apache.org/ant-tasks/

bernd_ruecker
Champ in-the-making
Champ in-the-making
I pasted the error above in the first post.
Yes, it cannot execute "dir"

tombaeyens
Champ in-the-making
Champ in-the-making
maybe i need to add dir.bat to the exe or dir.exe.
could you check if any of those two values for ls.executable works for you on windows bernd?

sorry for this, i was anticipating that this would only cause you trouble once we made the cutover…  i'll see if i can uncomment it in the meantime.  but i will need your help some time to verify that it works

joram is trying it out on windows now  (the .bat and .exe variants of the ls.executable)

christianlippha
Champ in-the-making
Champ in-the-making
Whoever fix this, have a look here for differences between windows / unix -> http://ant.apache.org/manual/Tasks/exec.html

Windows Users

The <exec> task delegates to Runtime.exec which in turn apparently calls ::CreateProcess. It is the latter Win32 function that defines the exact semantics of the call. In particular, if you do not put a file extension on the executable, only ".EXE" files are looked for, not ".COM", ".CMD" or other file types listed in the environment variable PATHEXT. That is only used by the shell.

Note that .bat files cannot in general by executed directly. One normally needs to execute the command shell executable cmd using the /c switch.

    <target name="help">
      <exec executable="cmd">
        <arg value="/c"/>
        <arg value="ant.bat"/>
        <arg value="-p"/>
      </exec>
    </target>


A common problem is not having the executable on the PATH. In case you get an error message Cannot run program "…":CreateProcess error=2. The system cannot find the path specified. have a look at your PATH variable. Just type the command directly on the command line and if Windows finds it, Ant should do it too. (Otherwise ask on the user mailinglist for help.) If Windows can not execute the program add the directory of the programm to the PATH (set PATH=%PATH%;dirOfProgram) or specify the absolute path in the executable attribute in your buildfile.

jbarrez
Star Contributor
Star Contributor
Thanks for the input.

The following works on Windows:

<exec output="test.txt" executable="cmd">
  <arg line="/c dir .." />
</exec>

However, it does produce a lot of unneeded other lines … (size, drive, etc)

jbarrez
Star Contributor
Star Contributor
Ok, this seems to do the trick:


<exec output="test.txt" executable="cmd">
  <arg line="/c dir /B .." />
</exec>

jbarrez
Star Contributor
Star Contributor
Ok, commited fix to trunk (r1255). I was able to build the distro with this fix.

Could you guys verify the distro build works again?

bernd_ruecker
Champ in-the-making
Champ in-the-making
Works 🙂 Thanks a lot!