Bug 10664 - wrapper script fails on cygwin if ANT_HOME is a Windows path
wrapper script fails on cygwin if ANT_HOME is a Windows path
Status: CLOSED FIXED
Product: Ant
Classification: Unclassified
Component: Wrapper scripts
1.5
Other other
: P3 normal (vote)
: 1.5.2
Assigned To: Ant Notifications List
:
: 10740 10743 10752 10784 11511 11872 12288 (view as bug list)
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2002-07-10 21:33 UTC by Patrick Taylor
Modified: 2004-11-16 19:05 UTC (History)
6 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Taylor 2002-07-10 21:33:33 UTC
If ANT_HOME is set to a Windows-style path (such as "C:\java\jakarta-ant-1.5"),
the ant startup script ($ANT_HOME/bin/ant) fails on cygwin.

The problem is that ANT_LIB is set to ${ANT_HOME}/lib before ANT_HOME is
changed to a UNIX path.  The fix is simply to set ANT_LIB after ANT_HOME
is changed.  Patch shown below.

*** ant.orig    Tue Jul  9 09:13:56 2002
--- ant Wed Jul 10 15:11:52 2002
***************
*** 69,77 ****
    cd $saveddir
  fi
  
- # set ANT_LIB location
- ANT_LIB=${ANT_HOME}/lib
- 
  # For Cygwin, ensure paths are in UNIX format before anything is touched
  if $cygwin ; then
    [ -n "$ANT_HOME" ] &&
--- 69,74 ----
***************
*** 82,87 ****
--- 79,87 ----
      CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  fi
  
+ # set ANT_LIB location
+ ANT_LIB=${ANT_HOME}/lib
+ 
  if [ -z "$JAVACMD" ] ; then 
    if [ -n "$JAVA_HOME"  ] ; then
      if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Comment 1 Stephane Bailliez 2002-07-10 21:46:51 UTC
Ooops. :-(

Thanks for the report. Fixed in CVS.
Comment 2 Stephane Bailliez 2002-07-12 14:53:50 UTC
*** Bug 10740 has been marked as a duplicate of this bug. ***
Comment 3 Stephane Bailliez 2002-07-12 15:22:08 UTC
*** Bug 10743 has been marked as a duplicate of this bug. ***
Comment 4 Stephane Bailliez 2002-07-12 18:37:58 UTC
*** Bug 10752 has been marked as a duplicate of this bug. ***
Comment 5 Stephane Bailliez 2002-07-14 10:07:08 UTC
*** Bug 10784 has been marked as a duplicate of this bug. ***
Comment 6 Stefan Bodewig 2002-07-16 07:11:52 UTC
A fixed version of the script is available, see
<http://jakarta.apache.org/ant/faq.html#1.5-cygwin-sh>.
Comment 7 Stefan Bodewig 2002-08-09 07:28:42 UTC
*** Bug 11511 has been marked as a duplicate of this bug. ***
Comment 8 Stephane Bailliez 2002-08-27 22:59:02 UTC
*** Bug 11872 has been marked as a duplicate of this bug. ***
Comment 9 Stefan Bodewig 2002-09-04 09:50:14 UTC
*** Bug 12288 has been marked as a duplicate of this bug. ***
Comment 10 Charlie Martin 2002-09-10 23:32:08 UTC
Script still blows chunks under Cygwin -- can't find the optional.jar file

Using the updated script from the FAQ, ant -verbose gives the following when
trying to execute a junit test.  Observe that the classpath contains
optional.jar and junit.jar (first line is echo of the final command before the
script executes it.)

511: ant -verbose
/cygdrive/c/j2sdk1.4.0_01/bin/java -classpath d:\Apache\jakarta-ant-1.5\lib\xml-
apis.jar;d:\Apache\jakarta-ant-1.5\lib\xercesImpl.jar;d:\Apache\jakarta-ant-1.5\
lib\optional.jar;d:\Apache\jakarta-ant-1.5\lib\ant.jar;c:\j2sdk1.4.0_01\lib\tool
s.jar -Dant.home=d:\Apache\jakarta-ant-1.5 -Dcygwin.user.home=D:\Cygwin\home\crm
artin org.apache.tools.ant.Main -verbose
Apache Ant version 1.5 compiled on July 9 2002
Buildfile: build.xml
Detected Java version: 1.4 in: c:\j2sdk1.4.0_01\jre
Detected OS: Windows 2000
parsing buildfile build.xml with URI = file:D:/Cygwin/home/crmartin/Projects/Cal
lgen/build.xml
Project base dir set to: D:\Cygwin\home\crmartin\Projects\Callgen
Build sequence for target `tested' is [prepare, compile, tests, tested]
Complete build sequence is [prepare, compile, tests, tested, clean]

prepare:

compile:
    [javac] sip\SIPMsg.java added as D:\Cygwin\home\crmartin\Projects\Callgen\co
mpiled\sip\SIPMsg.class doesn't exist.
    [javac] Compiling 1 source file to D:\Cygwin\home\crmartin\Projects\Callgen\
compiled
    [javac] Using modern compiler
    [javac] Compilation arguments:
    [javac] '-deprecation'
    [javac] '-d'
    [javac] 'D:\Cygwin\home\crmartin\Projects\Callgen\compiled'
    [javac] '-classpath'
    [javac] 'D:\Cygwin\home\crmartin\Projects\Callgen\compiled;D:\Cygwin\home\cr
martin\lib\junit.jar;D:\Cygwin\home\crmartin\lib\log4j.jar;D:\Cygwin\home\crmart
in\lib\or124.jar;D:\Apache\jakarta-ant-1.5\lib\xml-apis.jar;D:\Apache\jakarta-an
t-1.5\lib\xercesImpl.jar;D:\Apache\jakarta-ant-1.5\lib\optional.jar;D:\Apache\ja
karta-ant-1.5\lib\ant.jar;C:\j2sdk1.4.0_01\lib\tools.jar'
    [javac] '-sourcepath'
    [javac] 'D:\Cygwin\home\crmartin\Projects\Callgen\src'
    [javac] '-target'
    [javac] '1.4'
    [javac] '-g'
    [javac] '-source'
    [javac] '1.4'
    [javac]
    [javac] The ' characters around the executable and arguments are
    [javac] not part of the command.
    [javac] File to be compiled:
    [javac]     D:\Cygwin\home\crmartin\Projects\Callgen\src\sip\SIPMsg.java
    [javac] sip\SIPMsgTest.java added as D:\Cygwin\home\crmartin\Projects\Callge
n\compiled\sip\SIPMsgTest.class doesn't exist.
    [javac] Compiling 1 source file to D:\Cygwin\home\crmartin\Projects\Callgen\
compiled
    [javac] Using modern compiler
    [javac] Compilation arguments:
    [javac] '-deprecation'
    [javac] '-d'
    [javac] 'D:\Cygwin\home\crmartin\Projects\Callgen\compiled'
    [javac] '-classpath'
    [javac] 'D:\Cygwin\home\crmartin\Projects\Callgen\compiled;D:\Cygwin\home\cr
martin\lib\junit.jar;D:\Cygwin\home\crmartin\lib\log4j.jar;D:\Cygwin\home\crmart
in\lib\or124.jar;D:\Apache\jakarta-ant-1.5\lib\xml-apis.jar;D:\Apache\jakarta-an
t-1.5\lib\xercesImpl.jar;D:\Apache\jakarta-ant-1.5\lib\optional.jar;D:\Apache\ja
karta-ant-1.5\lib\ant.jar;C:\j2sdk1.4.0_01\lib\tools.jar'
    [javac] '-sourcepath'
    [javac] 'D:\Cygwin\home\crmartin\Projects\Callgen\test'
    [javac] '-target'
    [javac] '1.4'
    [javac] '-g'
    [javac] '-source'
    [javac] '1.4'
    [javac]
    [javac] The ' characters around the executable and arguments are
    [javac] not part of the command.
    [javac] File to be compiled:
    [javac]     D:\Cygwin\home\crmartin\Projects\Callgen\test\sip\SIPMsgTest.jav
a

tests:

BUILD FAILED
file:D:/Cygwin/home/crmartin/Projects/Callgen/build.xml:88: Could not create tas
k or type of type: junit.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
 - You have misspelt 'junit'.
   Fix: check your spelling.
 - The task needs an external JAR file to execute
   and this is not found at the right place in the classpath.
   Fix: check the documentation for dependencies.
   Fix: declare the task.
 - The task is an Ant optional task and optional.jar is absent
   Fix: look for optional.jar in ANT_HOME/lib, download if needed
 - The task was not built into optional.jar as dependent
   libraries were not found at build time.
   Fix: look in the JAR to verify, then rebuild with the needed
   libraries, or download a release version from apache.org
 - The build file was written for a later version of Ant
   Fix: upgrade to at least the latest release version of Ant
 - The task is not an Ant core or optional task
   and needs to be declared using <taskdef>.

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
        at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownEleme
nt.java:328)
        at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:24
4)
        at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.jav
a:115)
        at org.apache.tools.ant.Task.perform(Task.java:316)
        at org.apache.tools.ant.Target.execute(Target.java:309)
        at org.apache.tools.ant.Target.performTasks(Target.java:334)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
        at org.apache.tools.ant.Main.runBuild(Main.java:610)
        at org.apache.tools.ant.Main.start(Main.java:196)
        at org.apache.tools.ant.Main.main(Main.java:235)

Total time: 3 seconds
Comment 11 Charlie Martin 2002-09-11 17:53:33 UTC
Further info: the 1.4.1 ant script appears to work fine with the 1.5 jars, under
cygwin, and executes the tests that wouldn't execute noted above.
Comment 12 Stefan Bodewig 2002-09-26 08:23:12 UTC
Charlie, I don't see junit.jar in your CLASSPATH.
Comment 13 Charlie Martin 2002-09-27 16:30:32 UTC
Right -- but junit.jar is in the lib file along with the xerces etc., and when I
put the 1.4.1 ant script into the 1.5 bin dir, it works.
Comment 14 Stefan Bodewig 2002-09-30 12:58:32 UTC
and it is (sorry for being that verbose) D:\Apache\jakarta-ant-1.5\lib\junit.jar

This means the script picks up some of the jars in your lib directory - but
for some reason it doesn't pick all of them.  case-sensitivity?

The only relevant changes between the 1.4.1 and 1.5.1 versions I see are

-# add in the dependency .jar files
-DIRLIBS=${ANT_HOME}/lib/*.jar
-for i in ${DIRLIBS}
+# add in the dependency .jar files in non-RPM mode (the default)
+for i in "${ANT_LIB}"/*.jar

do you get a different result if you unfold the loop creation into two lines
like the 1.4.1 script has done?
Comment 15 Antoine Levy-Lambert 2003-05-13 22:46:26 UTC
can someone check if there is still an issue with this bug report in the CVS 
head ?
Note also that there are special classpath restrictions concerning the junit ant 
task in all environments, not just cygwin.
So maybe a large part of the bug report is to be seen more "JUnit specific" than 
"cygwin specific".
Comment 16 Antoine Levy-Lambert 2003-05-13 22:49:33 UTC
have a look at this URL concerning the classpath requirements of the ant JUnit 
task :
http://ant.apache.org/manual/OptionalTasks/junit.html
Comment 17 Antoine Levy-Lambert 2003-05-22 15:44:15 UTC
It looks like nobody is complaining about this issue any more. Stephane Bailliez 
fixed the bug with the revision 1.22. The bug fix is also in 1.19.2.6 so is 
fixed in ant 1.5.2 and higher.