Hello there!

        within a task I'm writing, I need to know the classpath entry
defined at <taskdef> time in the build file, or alternatively the whole
classpath used by ant to run the task (the reason is irrelevant, but for the
sake of it - within the task I need to load/access some of classes which are
defined in the same jar where the task resides).

        So far all I've come up with is checking whether the ClassLoader of
"this" is an org.apache.tools.ant.AntClassLoader, and if yes, cast and use
the getClassPath() method. The code's something like 

                String cp = System.getProperty("java.class.path");
                if (getClass().getClassLoader() instanceof AntClassLoader) 
                        cp=((AntClassLoader)
getClass().getClassLoader()).getClassPath();
                
        falling back on java.class.path if the ClassLoader isn't the
expected one.

        It works fine with cmdline ant but the problem is, IDEs like Eclipse
(I use the 3.0 something) use their own version of AntClassLoader with no
relationship with org.apache.tools.ant.AntClassLoader, so the same task
wouldnt work from there; besides, the solution it's pretty ugly.

        So, is there a better way to retrieve classpath information from
within a task - so that I can set up a ClassLoader able to go pick up
classes from the same place where the task is defined?

        Thanks,

                -cris





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to