ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Langr <JLa...@ezenia.com>
Subject custom taskdef requires Ant classloading of external JARs
Date Tue, 22 Feb 2005 18:57:00 GMT
Greetings,

I'm using Ant 1.6.1 under WinXP SP2.

I wrote a custom task, deployToCache, that reads from a URL; the URL can
sometimes be https. Here's the taskdef definition:

   <taskdef name="deployToCache"
classname="infoworkspace.build.DeployToCache">
       <classpath>
          <pathelement location="./DeployUtils.jar" />
       </classpath>
   </taskdef>


The custom task requires jnet.jar, jsse.jar, and jcert.jar. The relevant
code:

      System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
      Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

Access to the secure URL works fine when the code is run standalone, but
when it's run as the Ant task, the provider isn't getting picked up. I'm
aware that the custom task runs in Ant's Java process. If I change ant.bat
and alter Ant's classpath in the batch file, things work fine:

:runAntWithClasspath
setlocal
set SECUREJARS=c:\IWS251\CMBuild\ClassFiles\2512Classes
"%_JAVACMD%" %ANT_OPTS% -classpath
"%ANT_HOME%\lib\ant-launcher.jar;%SECUREJARS%\jsse.jar;%SECUREJARS%\jnet.jar
;%SECUREJARS%\jcert.jar" "-Dant.home=%ANT_HOME%"
org.apache.tools.ant.launch.Launcher %ANT_ARGS% -lib "%CLASSPATH%"
%ANT_CMD_LINE_ARGS%
endlocal
goto end

If I put the three jars (jnet, jsse, jcert) in Ant's lib directory, it does
not work. 

I tried also enhancing the <classpath> portion of the taskdef and adding the
JARs as pathelements:

   <taskdef name="deployToCache"
classname="infoworkspace.build.DeployToCache">
       <classpath>
          <pathelement location="./DeployUtils.jar" />
          <pathelement location="./jsse.jar" />
          <pathelement location="./jcert.jar" />
          <pathelement location="./jnet.jar" />
       </classpath>
   </taskdef>

That didn't work.

I looked at the Ant FAQ and didn't see anything that would help. The closest
entry seemed to be "<style> or <junit> ignores my <classpath>." 

I'd rather not require changes to ant.bat. I also tried setting the
CLASSPATH prior to executing ant.bat. Unfortunately this only sets the -lib
parameter on the Ant Java app command line; same problem.

One thing that does work is moving the three jars to the ext classloader
directory (jre/lib/ext), but I don't necessarily want to do that.

Thanks for any help.

Regards,
Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message