You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@apache.org on 2002/08/08 19:07:48 UTC

cvs commit: jakarta-ant/src/script ant antRun

costin      2002/08/08 10:07:48

  Modified:    src/script ant antRun
  Log:
  Submited the patch from Patrick.
  
  1. Removes the extraneous "cd `dirname $PRG`" line that causes the
      script to break when Ant is invoked with from a relative path
      (i.e. ../jakarta-ant/bin/ant).
  
  2. Properly quote all environment variables that may contain paths.
      The script would break if any of these environment variables
      contained paths with spaces in them (a common occurrence on Windows).
  
  3. Invoke Java using the "exec" shell command. There really is no need
      to create a child process to run the JVM and by using the "exec"
      command, there is less chance that killing the script will fail to
      kill Ant.
  
  Submitted by:	 Patrick Luby <pa...@sun.com>
  
  Revision  Changes    Path
  1.24      +15 -18    jakarta-ant/src/script/ant
  
  Index: ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/script/ant,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ant	12 Jul 2002 15:15:46 -0000	1.23
  +++ ant	8 Aug 2002 17:07:48 -0000	1.24
  @@ -44,20 +44,18 @@
     fi
   
     ## resolve links - $0 may be a link to ant's home
  -  PRG=$0
  -  progname=`basename $0`
  +  PRG="$0"
  +  progname=`basename "$0"`
     saveddir=`pwd`
   
     # need this for relative symlinks
  -  cd `dirname $PRG`
  -  
     while [ -h "$PRG" ] ; do
       ls=`ls -ld "$PRG"`
       link=`expr "$ls" : '.*-> \(.*\)$'`
       if expr "$link" : '.*/.*' > /dev/null; then
   	PRG="$link"
       else
  -	PRG="`dirname $PRG`/$link"
  +	PRG=`dirname "$PRG"`"/$link"
       fi
     done
     
  @@ -80,7 +78,7 @@
   fi
   
   # set ANT_LIB location
  -ANT_LIB=${ANT_HOME}/lib
  +ANT_LIB="${ANT_HOME}/lib"
   
   if [ -z "$JAVACMD" ] ; then 
     if [ -n "$JAVA_HOME"  ] ; then
  @@ -107,18 +105,18 @@
   
   # in rpm_mode get ant/optional/xml parser&api from JAVALIBDIR 
   if $rpm_mode; then
  -  JAVALIBDIR=/usr/share/java
  +  JAVALIBDIR="/usr/share/java"
     for i in ant ant-optional jaxp_parser xml_apis 
     do
       if [ -z "$LOCALCLASSPATH" ] ; then
  -      LOCALCLASSPATH=$JAVALIBDIR/$i.jar
  +      LOCALCLASSPATH="$JAVALIBDIR/$i.jar"
       else
  -      LOCALCLASSPATH="$JAVALIBDIR/$i.jar":"$LOCALCLASSPATH"
  +      LOCALCLASSPATH="$JAVALIBDIR/$i.jar:$LOCALCLASSPATH"
       fi
     done
   
   # in rpm mode ant/lib is in /usr/share/java/ant
  -ANT_LIB=${JAVALIBDIR}/ant
  +ANT_LIB="${JAVALIBDIR}/ant"
   
   fi
   
  @@ -127,11 +125,11 @@
   do
     # if the directory is empty, then it will return the input string
     # this is stupid, so case for it
  -  if [ "$i" != "${ANT_LIB}/*.jar" ] ; then
  +  if [ -f "$i" ] ; then
       if [ -z "$LOCALCLASSPATH" ] ; then
  -      LOCALCLASSPATH=$i
  +      LOCALCLASSPATH="$i"
       else
  -      LOCALCLASSPATH="$i":"$LOCALCLASSPATH"
  +      LOCALCLASSPATH="$i:$LOCALCLASSPATH"
       fi
     fi
   done
  @@ -148,10 +146,10 @@
     # OSX hack to make Ant work with jikes
     if $darwin ; then
       OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes"
  -    if [ -d ${OSXHACK} ] ; then
  -      for i in ${OSXHACK}/*.jar
  +    if [ -d "${OSXHACK}" ] ; then
  +      for i in "${OSXHACK}"/*.jar
         do
  -        JIKESPATH=$JIKESPATH:$i
  +        JIKESPATH="$JIKESPATH:$i"
         done
       fi
     fi
  @@ -167,7 +165,6 @@
     if $cygwin ; then
       JIKESPATH=`cygpath --path --windows "$JIKESPATH"`
     fi
  -  ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
   fi
   
   # Allow Jikes support (off by default)
  @@ -184,4 +181,4 @@
     ANT_OPTS="$ANT_OPTS -Dcygwin.user.home="`cygpath --path --windows "$HOME"`
   fi
   
  -"$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
  +exec "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
  
  
  
  1.3       +1 -1      jakarta-ant/src/script/antRun
  
  Index: antRun
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/script/antRun,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- antRun	10 Jan 2002 14:18:42 -0000	1.2
  +++ antRun	8 Aug 2002 17:07:48 -0000	1.3
  @@ -9,4 +9,4 @@
   shift
   shift
   
  -exec $CMD "$@"
  +exec "$CMD" "$@"
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PATCH] jakarta-ant/src/script/ant

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 09 Aug 2002, Patrick Luby <pa...@sun.com> wrote:
> Attach is a patch that handles $JIKESPATH if it has spaces and
> leaves the jikes.class.path system property null when $JIKESPATH is
> undefined.

Thanks, committed.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[PATCH] jakarta-ant/src/script/ant

Posted by Patrick Luby <pa...@sun.com>.
Attach is a patch that handles $JIKESPATH if it has spaces and leaves 
the jikes.class.path system property null when $JIKESPATH is undefined.

Patrick

-- 
________________________________________________________________
Patrick Luby                     Email: patrick.luby@sun.com
Sun Microsystems                         Phone: 408-276-7471
901 San Antonio Road, USCA14-303
Palo Alto, CA 94303-4900
________________________________________________________________

Re: cvs commit: jakarta-ant/src/script ant antRun

Posted by Patrick Luby <pa...@sun.com>.
Stefan,

Stefan Bodewig wrote:
> 
> Well, this is where I could test it as well (plus FreeBSD), but I'm
> always suprosed to see how many people prefer to run ant in Cygwin
> over ant.bat.
> 
> And lots of things in the ant script are due to Cygwin problems.
> 

Many times, this is due to the use of spaces in paths. After all, spaces 
are very common in Windows paths but are really a pain to deal with in 
both batch and shell scripts.

> 
> Thanks.  I'm currently patching the script to contain a modified
> version of the one in
> <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10654>, maybe you
> better wait a few minutes (or I'll have to merge, no problem).
> 

I just saw your commit. You used the same approach for CYGHOME as I was 
going to use for JIKESPATH: construct a different command depending on 
whether JIKESPATH is defined or not. Unfortunately, the script gets a 
little obtuse with 4 possible combinations of JIKESPATH and CYGHOME. 
Unfortunately, it is the best we have. Also, it is probably the only way 
to do it in the batch script ant.bat since you cannot put "=" characters 
in environment variables on Windows 95, 98, and ME.

> 
> No idea, I'm not using jikes on MacOS, but I'm sure Jon Stevens would
> catch it (most "if $darwin" stuff is his).
 >

I will leave the Mac OS X stuff alone for now. But I have been able to 
run the <javac> quite nicely without the JIKESPATH hack on my Mac OS X 
machine since the 10.0 release.
> 
> BTW, if you remove the "extraneous cd", the cd "$savedir" is obsolete
> as well, no?
> 

Yes. This can be removed as well.

> Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- 
________________________________________________________________
Patrick Luby                     Email: patrick.luby@sun.com
Sun Microsystems                         Phone: 408-276-7471
901 San Antonio Road, USCA14-303
Palo Alto, CA 94303-4900
________________________________________________________________


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-ant/src/script ant antRun

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 09 Aug 2002, Patrick Luby <pa...@sun.com> wrote:

>> Has this been tested under Cygwin?
> 
> Not Cygwin. But I have tried Solaris, Linux, and Mac OS X.

Well, this is where I could test it as well (plus FreeBSD), but I'm
always suprosed to see how many people prefer to run ant in Cygwin
over ant.bat.

And lots of things in the ant script are due to Cygwin problems.

> We have been using "exec" in the Tomcat 4.x scripts for quite some
> time now without ill effect.

Good to know.

> I will post a patch in a few minutes that reverts the JIKESPATH
> always == "" problem.

Thanks.  I'm currently patching the script to contain a modified
version of the one in
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10654>, maybe you
better wait a few minutes (or I'll have to merge, no problem).

> Note, however, that Mac OS X will not have JIKESPATH set like in the
> old script.

No idea, I'm not using jikes on MacOS, but I'm sure Jon Stevens would
catch it (most "if $darwin" stuff is his).

BTW, if you remove the "extraneous cd", the cd "$savedir" is obsolete
as well, no?

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-ant/src/script ant antRun

Posted by Patrick Luby <pa...@sun.com>.
Stefan,

Stefan Bodewig wrote:
> On 8 Aug 2002, <co...@apache.org> wrote:
> 
> 
>>  1. Removes the extraneous "cd `dirname $PRG`" line
>>  
>>  3. Invoke Java using the "exec" shell command.
> 
> 
> Has this been tested under Cygwin?

Not Cygwin. But I have tried Solaris, Linux, and Mac OS X.

> 
> I'm not sure whether exec works as expected there and cannot test it,
> that's why I've kept away from that patch.
> 

We have been using "exec" in the Tomcat 4.x scripts for quite some time 
now without ill effect.

> Also
> 
> 
>>  @@ -167,7 +165,6 @@
>>     if $cygwin ; then
>>       JIKESPATH=`cygpath --path --windows "$JIKESPATH"`
>>     fi
>>  -  ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
>>   fi
> 
> 
> <snip/>
> 
>>  -Djikes.class.path="$JIKESPATH" $ANT_OPTS
> 
> 
> changes things a bit.  In the old version jikes.class.path would be
> left unset if the environment variable JIKESPATH was unset (and you
> are not on MacOS X).  Now this property will be always defined, but
> may get an empty value.
> 

I can generate a reversion of this part of the patch. However, there is 
a bit of a problem. Previously, -Djikes.class.path=$JIKESPATH was 
appended onto $ANT_OPTS and then $ANT_OPTS is included in the Java 
command. The problem is that if $JIKESPATH contains spaces, the above 
will break into 2 arguments: -Djikes.class.path=... and ... The only way 
around this is to explicitly put -Djikes.class.path="$JIKESPATH" in the 
Java command.

> There certainly is a difference between a property that is not set and
> an empty one (see if/unless attributes) and the jikes compiler adapter
> behaves differently as well:
> 
>         String jikesPath = System.getProperty("jikes.class.path");
>         if (jikesPath != null) {
>             classpath.append(new Path(project, jikesPath));
>         }
> 
> which may lead to adding an empty entry to the classpath before
> invoking jikes.

Looking at the o.a.t.a.types.Path code, an empty String looks like it 
will turn into the current working directory :(. This is probably why I 
never found a problem with this change.

> 
> Could you please revert at least this last part of the patch?

I will post a patch in a few minutes that reverts the JIKESPATH always 
== "" problem. Note, however, that Mac OS X will not have JIKESPATH set 
like in the old script. This is because since the Mac OS X official 
release, the compiler classes are included in the bootstrap classpath. I 
believe that the setting of JIKESPATH for Mac OS X is leftover from the 
pre-release versions of Mac OS X.

Patrick

-- 
________________________________________________________________
Patrick Luby                     Email: patrick.luby@sun.com
Sun Microsystems                         Phone: 408-276-7471
901 San Antonio Road, USCA14-303
Palo Alto, CA 94303-4900
________________________________________________________________


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-ant/src/script ant antRun

Posted by Stefan Bodewig <bo...@apache.org>.
On 8 Aug 2002, <co...@apache.org> wrote:

>   1. Removes the extraneous "cd `dirname $PRG`" line
>   
>   3. Invoke Java using the "exec" shell command.

Has this been tested under Cygwin?

I'm not sure whether exec works as expected there and cannot test it,
that's why I've kept away from that patch.

Also

>   @@ -167,7 +165,6 @@
>      if $cygwin ; then
>        JIKESPATH=`cygpath --path --windows "$JIKESPATH"`
>      fi
>   -  ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
>    fi

<snip/>

>   -Djikes.class.path="$JIKESPATH" $ANT_OPTS

changes things a bit.  In the old version jikes.class.path would be
left unset if the environment variable JIKESPATH was unset (and you
are not on MacOS X).  Now this property will be always defined, but
may get an empty value.

There certainly is a difference between a property that is not set and
an empty one (see if/unless attributes) and the jikes compiler adapter
behaves differently as well:

        String jikesPath = System.getProperty("jikes.class.path");
        if (jikesPath != null) {
            classpath.append(new Path(project, jikesPath));
        }

which may lead to adding an empty entry to the classpath before
invoking jikes.

Could you please revert at least this last part of the patch?

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>