Bug 141058

Summary: ant.home not set by ant binary (but is set by classic-ant script)
Product: [Fedora] Fedora Reporter: Daniel L. Rall <dlr>
Component: antAssignee: Vadim Nasardinov <vnasardinov>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: mattdm
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-11-10 20:58:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
bz141058.sh none

Description Daniel L. Rall 2004-11-28 23:59:02 UTC
Description of problem:

The ant.home system property (e.g. System.getProperty()) is not set as
for the gcj-compiled binary.  This problem is not present for the
classic-ant shell script.

This is especially important when writing Ant extensions while compile
against Ant itself (or its existing set of optional extension Tasks).

See revision 106859 of Velocity DVSL
<http://svn.apache.org/viewcvs.cgi/jakarta/velocity-dvsl/trunk/> for
an example of a work-around I had to write for this problem (build.xml
and default.properties were affected by the change).

Version-Release number of selected component (if applicable):

$ rpm -q ant
ant-1.5.2-26


How reproducible:

Try using the ant.home property.  For instance, try setting ant.jar to
${ant.home}/lib/ant.jar.

  
Actual results:

ant.home is not set, meaning that any JAR file path set relative to to
ant.home is unusable.

Expected results:

ant.home should always be set per ant script.


Additional info:

You can sometimes use the ANT_HOME environment variable as a
work-around, but this is not always set (its what ant.home is derived
from in classic-ant).

Comment 1 Daniel L. Rall 2004-11-29 21:46:24 UTC
Incidently, here's how ant.home gets set from the ANT_HOME environment
variable in the classic-ant shell script:

$ grep 'ant\.home' `which classic-ant`
    "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH"
-Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH"
-Dcygwin.user.home="$CYGHOME" org.apache.tools.ant.Main $ANT_ARGS "$@"
    "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH"
-Dant.home="${ANT_HOME}" -Dcygwin.user.home="$CYGHOME"
org.apache.tools.ant.Main $ANT_ARGS "$@"
    "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH"
-Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH"
org.apache.tools.ant.Main $ANT_ARGS "$@"
    "$JAVACMD" $ANT_OPTS -classpath "$LOCALCLASSPATH"
-Dant.home="${ANT_HOME}" org.apache.tools.ant.Main $ANT_ARGS "$@"


Comment 3 Matthew Miller 2005-04-26 15:25:20 UTC
Fedora Core 2 is now maintained by the Fedora Legacy project for
security updates only. If this problem is a security issue, please
reopen and reassign to the Fedora Legacy product. If it is not a
security issue and hasn't been resolved in the current FC3 updates or
in the FC4 test release, reopen and change the version to match.

Comment 4 Daniel L. Rall 2005-04-26 19:16:51 UTC
Due to the native-compiled version of the ant executable, this is still a
problem in FC3, and will be a problem in FC4 as well.  Please let me know what
additional information I can provide.

Comment 5 Matthew Miller 2005-04-26 19:24:02 UTC
Thanks. I'm going to set this to version "devel" for FC4.

Comment 6 Gary Benson 2005-04-27 08:21:33 UTC
This won't be an issue for FC4.  Current rawhide has bytecode ant, and the new
BC ABI in libgcj means that stuff shouldn't break when we roll out the native
stuff (Real Soon Nowâ¢).

Comment 7 Daniel L. Rall 2005-04-27 22:51:16 UTC
Gary, thanks for the feedback!  This bytecode API sounds like a major
improvement which will likely fix a ton of the classloading issues I've seen
with the native-compiled ant binary.  However, I'm unsure how it alone could fix
the setting of ant.home, a java.lang.System property which is set for the JVM by
all the traditional Ant invocation wrapper scripts, and assumed by many Ant
tasks and build.xml files to be available.

To fix this issue, it seems to me that some additional code would need to be
executed by the gcj-compiled binary on startup which performs the additional
operations handled by the traditional wrapper scripts (operations which occur
before any Java bytecode is ever executed).  Missing the ant.home system
property is only once instance of this class of problem; note other system
properties like jikes.class.path and cygwin.user.home which are set by the
snippet of the traditional shell wrapper script which I pasted into comment #1.

For most developer/end users of Ant, Ant is more than the its Java bytecodes. 
It's also that set of wrapper scripts which insulate the user from environment
specific issues which they'd prefer not to have to know about.  :-)

Comment 8 Gary Benson 2005-04-28 08:57:09 UTC
In FC4 we're using the standard ant wrapper scripts -- the gcj-compiled binary
is history.

Comment 9 Vadim Nasardinov 2005-11-10 20:56:02 UTC
Created attachment 120903 [details]
bz141058.sh

simple test case

Comment 10 Vadim Nasardinov 2005-11-10 20:58:18 UTC
Seems to work in FC4:

|$ curl -o bz141058.sh \
|  'https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=120903'
|  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
|                                 Dload  Upload   Total   Spent    Left  Speed
|100   242  100   242    0     0    290      0 --:--:-- --:--:-- --:--:--  236k
|$ bash bz141058.sh
|Buildfile: /dev/fd/63
|
|test:
|     [echo] ant.home=/usr/share/ant
|
|BUILD SUCCESSFUL
|Total time: 1 second


Closing.


Comment 11 Daniel L. Rall 2005-11-11 00:13:01 UTC
Nice work guys.  Verified on FC4.