You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Sean Ogle <se...@syslog.at> on 2001/03/07 19:04:40 UTC

antRun and antRun.bat problems?

Has anybody had problems compiling with jikes with respect to ant's use of
the antRun and antRun.bat files in the ${ANT_HOME}/bin directory? I had to
re-type the antRun file in linux because it had some embedded characters
which I couldn't see in Emacs (probably ^A or ^D ?). But now that works and
I am trying to run my script on Win 2K and it chokes in the antRun.bat file.
The third line starts with a # character which is supposedly a comment even
though Win2K uses 'rem' to start comment lines. But even worse, Win2K
appears to be breaking the classpath up at ; characters!

Check this out (from 'ant -debug deploy')
...
Execute:Java13CommandLauncher: jikes -d H:\work\java\classes -classpath
H:\work\
java\classes;H:\work\java;C:\jdk1.3.0_02\jre\lib\rt.jar +E
H:\work\java\at\syslo
g\JZorro.java

BUILD FAILED

H:\work\java\at\syslog\jzorro\build.xml:53: Error running jikes compiler
--- Nested Exception ---
java.io.IOException: CreateProcess: jikes -d H:\work\java\classes -classpath
H:\
work\java\classes;H:\work\java;C:\jdk1.3.0_02\jre\lib\rt.jar +E
H:\work\java\at\
syslog\JZorro.java error=2
        at java.lang.Win32Process.create(Native Method)
        at java.lang.Win32Process.<init>(Win32Process.java:66)
        at java.lang.Runtime.execInternal(Native Method)
        at java.lang.Runtime.exec(Runtime.java:551)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:509)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:329)
        at
org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.execut
eExternalCompile(DefaultCompilerAdapter.java:329)
        at
org.apache.tools.ant.taskdefs.compilers.Jikes.execute(Jikes.java:201)

        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:461)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.Project.executeTargets(Project.java:510)
        at org.apache.tools.ant.Main.runBuild(Main.java:421)
        at org.apache.tools.ant.Main.main(Main.java:149)
So I tried to use the antRun.bat file with a command like this:

H:\work\java\at\syslog\jzorro>%ANT_HOME%\bin\antRun.bat h:\work\java
jikes -d H:
\work\java\classes -classpath
H:\work\java\classes;H:\work\java;C:\jdk1.3.0_02\j
re\lib\rt.jar +E H:\work\java\at\syslog\JZorro.java

after modifying the antRun.bat file to this:

@echo off

rem Change drive and directory to %1 (Win9X only for NT/2K use "cd /d")
cd %1
rem cd /d
rem %1\
set ANT_RUN_CMD=%2
shift
shift

set PARAMS=
:loop
echo %1
if ""%1 == "" goto runCommand
set PARAMS=%PARAMS% %1
shift
goto loop

:runCommand
echo %ANT_RUN_CMD% %PARAMS%
rem %ANT_RUN_CMD% %PARAMS%

Notice that I am not actually running the command but looking at what it is
doing instead and I get this:

-d
H:\work\java\classes
-classpath
H:\work\java\classes
H:\work\java
C:\jdk1.3.0_02\jre\lib\rt.jar
+E
H:\work\java\at\syslog\JZorro.java
ECHO is off.
jikes  -d H:\work\java\classes -classpath H:\work\java\classes H:\work\java
C:\j
dk1.3.0_02\jre\lib\rt.jar +E H:\work\java\at\syslog\JZorro.java

which clearly won't work (notice the class path).

Unfortunately I am not a Win2K batch file guru and am not sure how to
proceed. This must be simple to fix.

But the real question is why am I having this problem in the first place?

Any help would be appreciated! Thanks.

Sean


AW: antRun and antRun.bat problems?

Posted by Sean Ogle <se...@syslog.at>.
Thanks Bill,

After much digging through the code I discovered these facts for myself. I
was still having problems with ant and jikes on Win2K though so I changed my
version of the code to run the Runtime.exec() method with "cmd /c" inserted
into the beginning of the command string. Everything works fine now.

Sean

-----Ursprungliche Nachricht-----
Von: Bill Burton [mailto:billb@progress.com]
Gesendet: Sonntag, 11. Marz 2001 04:42
An: ant-user@jakarta.apache.org
Betreff: Re: antRun and antRun.bat problems?


Hi Sean,

The antRun scripts are used internally by Ant with the <exec> task it it's
subclasses like <execon> and I believe <apply> along with possibly other
tasks.  The sole purpose of these scripts is to change to a different
directory before executing the specified command.  As such you shouldn't
be trying to invoke antRun from the command line as that's not it's
intended purpose.  The antRun scripts are only called by <exec> and
friends when:
  * You are running under Windows 9x/Me or any UNIX/Linux OS and not
running a 1.3 JVM and you specify a "dir" attribute with a value that
resolves to something other than the directory from which Ant was invoked.

They are not called when:
  * You are running with a 1.3 JVM on any platform.  A new version of the
Runtime.exec method in 1.3 supports an argument with the directory in
which the command should be run in.
  * You are running on Windows NT or 2000 under a 1.2.2 JVM.
  * You don't specify a "dir" attribute or do specify one with a value
equivalent to the current directory from which Ant was invoked.

FYI, you can verify how external commands are invoked when running with
the -debug option (on v1.3 or greater).  Any external command executed by
Ant shows up with the line: Execute:FooCommandLauncher: command-to-execute
...  where "Foo" is the name of the inner class of the Execute class
implementing a type of command launcher.  The command shown is
subsequently handed off to Java's Runtime.exec method.  So if the antRun
script is being called, you will see it there as the first argument.

The newline problem was fixed in CVS recently and should be available in a
nightly build of 1.4 Alpha.  Otherwise, you can fix this yourself by using
an editor or utility that supports newline conversion or even Ant's
<fixCRLF> task.

-Bill

Sean Ogle wrote:
>
> Has anybody had problems compiling with jikes with respect to ant's use of
> the antRun and antRun.bat files in the ${ANT_HOME}/bin directory? I had to
> re-type the antRun file in linux because it had some embedded characters
> which I couldn't see in Emacs (probably ^A or ^D ?). But now that works
and
> I am trying to run my script on Win 2K and it chokes in the antRun.bat
file.
> The third line starts with a # character which is supposedly a comment
even
> though Win2K uses 'rem' to start comment lines. But even worse, Win2K
> appears to be breaking the classpath up at ; characters!


Re: antRun and antRun.bat problems?

Posted by Bill Burton <bi...@progress.com>.
Hi Sean,

The antRun scripts are used internally by Ant with the <exec> task it it's
subclasses like <execon> and I believe <apply> along with possibly other
tasks.  The sole purpose of these scripts is to change to a different
directory before executing the specified command.  As such you shouldn't
be trying to invoke antRun from the command line as that's not it's
intended purpose.  The antRun scripts are only called by <exec> and
friends when:
  * You are running under Windows 9x/Me or any UNIX/Linux OS and not
running a 1.3 JVM and you specify a "dir" attribute with a value that
resolves to something other than the directory from which Ant was invoked.

They are not called when:
  * You are running with a 1.3 JVM on any platform.  A new version of the
Runtime.exec method in 1.3 supports an argument with the directory in
which the command should be run in.
  * You are running on Windows NT or 2000 under a 1.2.2 JVM.
  * You don't specify a "dir" attribute or do specify one with a value
equivalent to the current directory from which Ant was invoked.

FYI, you can verify how external commands are invoked when running with
the -debug option (on v1.3 or greater).  Any external command executed by
Ant shows up with the line: Execute:FooCommandLauncher: command-to-execute
...  where "Foo" is the name of the inner class of the Execute class
implementing a type of command launcher.  The command shown is
subsequently handed off to Java's Runtime.exec method.  So if the antRun
script is being called, you will see it there as the first argument.

The newline problem was fixed in CVS recently and should be available in a
nightly build of 1.4 Alpha.  Otherwise, you can fix this yourself by using
an editor or utility that supports newline conversion or even Ant's
<fixCRLF> task.

-Bill

Sean Ogle wrote:
> 
> Has anybody had problems compiling with jikes with respect to ant's use of
> the antRun and antRun.bat files in the ${ANT_HOME}/bin directory? I had to
> re-type the antRun file in linux because it had some embedded characters
> which I couldn't see in Emacs (probably ^A or ^D ?). But now that works and
> I am trying to run my script on Win 2K and it chokes in the antRun.bat file.
> The third line starts with a # character which is supposedly a comment even
> though Win2K uses 'rem' to start comment lines. But even worse, Win2K
> appears to be breaking the classpath up at ; characters!

Re: antRun and antRun.bat problems?

Posted by Michael Twomey <mi...@ireland.sun.com>.
I recently logged bug 837
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=837) about this. It
appears that DOS style carriage returns have crept into antRun which
causes it to fail on UNIX. It basically manifests itself in <exec> tasks
failing (the only hint as to why is that the tasks return -1).

cheers,
	mick

Sean Ogle wrote:
> 
> Has anybody had problems compiling with jikes with respect to ant's use of
> the antRun and antRun.bat files in the ${ANT_HOME}/bin directory? I had to
> re-type the antRun file in linux because it had some embedded characters
> which I couldn't see in Emacs (probably ^A or ^D ?). But now that works and
> I am trying to run my script on Win 2K and it chokes in the antRun.bat file.
> The third line starts with a # character which is supposedly a comment even
> though Win2K uses 'rem' to start comment lines. But even worse, Win2K
> appears to be breaking the classpath up at ; characters!
> 
> Check this out (from 'ant -debug deploy')
> ...
> Execute:Java13CommandLauncher: jikes -d H:\work\java\classes -classpath
> H:\work\
> java\classes;H:\work\java;C:\jdk1.3.0_02\jre\lib\rt.jar +E
> H:\work\java\at\syslo
> g\JZorro.java
> 
> BUILD FAILED
> 
> H:\work\java\at\syslog\jzorro\build.xml:53: Error running jikes compiler
> --- Nested Exception ---
> java.io.IOException: CreateProcess: jikes -d H:\work\java\classes -classpath
> H:\
> work\java\classes;H:\work\java;C:\jdk1.3.0_02\jre\lib\rt.jar +E
> H:\work\java\at\
> syslog\JZorro.java error=2
>         at java.lang.Win32Process.create(Native Method)
>         at java.lang.Win32Process.<init>(Win32Process.java:66)
>         at java.lang.Runtime.execInternal(Native Method)
>         at java.lang.Runtime.exec(Runtime.java:551)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at
> org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
> ute.java:509)
>         at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:329)
>         at
> org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.execut
> eExternalCompile(DefaultCompilerAdapter.java:329)
>         at
> org.apache.tools.ant.taskdefs.compilers.Jikes.execute(Jikes.java:201)
> 
>         at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:461)
>         at org.apache.tools.ant.Target.execute(Target.java:153)
>         at org.apache.tools.ant.Project.runTarget(Project.java:898)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:536)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:510)
>         at org.apache.tools.ant.Main.runBuild(Main.java:421)
>         at org.apache.tools.ant.Main.main(Main.java:149)
> So I tried to use the antRun.bat file with a command like this:
> 
> H:\work\java\at\syslog\jzorro>%ANT_HOME%\bin\antRun.bat h:\work\java
> jikes -d H:
> \work\java\classes -classpath
> H:\work\java\classes;H:\work\java;C:\jdk1.3.0_02\j
> re\lib\rt.jar +E H:\work\java\at\syslog\JZorro.java
> 
> after modifying the antRun.bat file to this:
> 
> @echo off
> 
> rem Change drive and directory to %1 (Win9X only for NT/2K use "cd /d")
> cd %1
> rem cd /d
> rem %1\
> set ANT_RUN_CMD=%2
> shift
> shift
> 
> set PARAMS=
> :loop
> echo %1
> if ""%1 == "" goto runCommand
> set PARAMS=%PARAMS% %1
> shift
> goto loop
> 
> :runCommand
> echo %ANT_RUN_CMD% %PARAMS%
> rem %ANT_RUN_CMD% %PARAMS%
> 
> Notice that I am not actually running the command but looking at what it is
> doing instead and I get this:
> 
> -d
> H:\work\java\classes
> -classpath
> H:\work\java\classes
> H:\work\java
> C:\jdk1.3.0_02\jre\lib\rt.jar
> +E
> H:\work\java\at\syslog\JZorro.java
> ECHO is off.
> jikes  -d H:\work\java\classes -classpath H:\work\java\classes H:\work\java
> C:\j
> dk1.3.0_02\jre\lib\rt.jar +E H:\work\java\at\syslog\JZorro.java
> 
> which clearly won't work (notice the class path).
> 
> Unfortunately I am not a Win2K batch file guru and am not sure how to
> proceed. This must be simple to fix.
> 
> But the real question is why am I having this problem in the first place?
> 
> Any help would be appreciated! Thanks.
> 
> Sean

-- 
Michael Twomey
These opinions are my own and do not represent Sun unless otherwise
stated.
Sun Microsystems, Dublin, 8199164, x19164
"Fly my little Makefiles! Fly!"