You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Asle Pedersen <ap...@gmail.com> on 2005/07/12 16:40:27 UTC

storing optional (ftp) task jar dependency under my project instead of under /ant/lib

Is it possible to "embed" the ant ftp task in a project. I would like
to just depend on a standard ant-installation to use the ftp task and
have the commons-net-1.1.0.jar in my project instead of under /ant/lib
which is suggested by the documentation. I have tried different
methods to do this but none have worked so far. Any suggestions?

Regards,
Asle

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


Re: storing optional (ftp) task jar dependency under my project instead of under /ant/lib

Posted by Peter Reilly <pe...@apache.org>.
Asle Pedersen wrote:

>Ok, in that case alt.3 is not very attractive afterall. I don't know
>if it is just me but I prefer do embed this type of behaviour in the
>build.xml and project itself.
>  
>
Indeed,
I would argue that the whole idea of spitting the optional ant tasks 
into a relatively
large number of jar files to work-around the classloading probem was not 
a good idea.
To make use of it, one has to modify the ant distribution.

Peter

>I have had similar problems with system environment variables in
>particular charset encodings which need to be set outside of the
>build.xml. Instead of just executing the build.xml this causes me to
>have a shellscript to set the environment variables and execute the
>build.xml
>
>What I could do in this particular case is provide an install
>mechanism (a target in the build.xml perhaps) for the ftp-task which
>copies the commons-net-1.1.0.jar from the projects lib directory into
>$HOME\.ant\lib. That way it would be fairly straightforward to use.
>
>/A 
>
>
>On 7/12/05, Peter Reilly <pe...@apache.org> wrote:
>  
>
>>Asle Pedersen wrote:
>>
>>    
>>
>>>I prefer alt.3 and try using taskdefs before without success. I did
>>>try it again now also not successfully. Could you please supply me
>>>with a complete working example?
>>>
>>>This is how my (non-working) build.xml looks like now:
>>>(both .jar files are placed in the lib directory under the basedir)
>>>
>>><project name="imweb" default="upload" basedir=".">
>>>
>>>      <taskdef name="ftp" classname="org.apache.tools.ant.taskdefs.optional.net.FTP">
>>>       <classpath>
>>>         <pathelement location="/lib/ant-commons-net.jar"/>
>>>         <pathelement location="/lib/commons-net-1.1.0.jar"/>
>>>       </classpath>
>>>      </taskdef>
>>>
>>>      <target name="upload">
>>>              <ftp server="..." userid="... password="..." depends="yes" verbose="yes">
>>>                      <fileset dir="en" />
>>>              </ftp>
>>>      </target>
>>></project>
>>>
>>>Is it really necessary to place ant-commons-net in the classpath since
>>>it is already under the ant/lib path? btw! I am using ant.1.6.5
>>>
>>>
>>>      
>>>
>>See the FAQ on classloading.
>>Option number 3, as Ivan says, *requires" moving ant-commons-net.jar
>>out of the ant lib directory to some place else, otherwise the
>>ant-commons-net.jar gets
>>loaded at ant startup time (sort of, it is in the startup classpath), and
>>at this time (with this classpath) it cannot see the commons net classes
>>so the task will not start.
>>Peter
>>
>>    
>>
>>>Regards,
>>>Asle
>>>
>>>
>>>
>>>On 7/12/05, Ivan Ivanov <ra...@yahoo.com> wrote:
>>>
>>>
>>>      
>>>
>>>>Asle,
>>>>
>>>>You have several other alternatives to keep your ant
>>>>distribution clean of external libs:
>>>>1) Put commons-net-1.1.0.jar in $HOME\.ant\lib (my
>>>>favourite way)
>>>>2) Place it an arbitrary directory say
>>>>/path/to/thirdparty/jars and use -lib option of ant
>>>>launching script.
>>>>
>>>>3) (Requires more coding and its benefits are
>>>>doubtful). Move ant-commons-net.jar from $ANT_HOME/lib
>>>>to some other folder and in your build script
>>>><taskdef> ftp task like this:
>>>><taskdef name="ftp" classname="...">
>>>> <classpath>
>>>>   <pathelement
>>>>location="/path/to/ant-commons-net.jar"/>
>>>>   <pathelement location="/path/to/commons-net.jar"/>
>>>> </classpath>
>>>></taskdef>
>>>>
>>>>Regards
>>>>Ivan
>>>>
>>>>--- Asle Pedersen <ap...@gmail.com> wrote:
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>>>Is it possible to "embed" the ant ftp task in a
>>>>>project. I would like
>>>>>to just depend on a standard ant-installation to use
>>>>>the ftp task and
>>>>>have the commons-net-1.1.0.jar in my project instead
>>>>>of under /ant/lib
>>>>>which is suggested by the documentation. I have
>>>>>tried different
>>>>>methods to do this but none have worked so far. Any
>>>>>suggestions?
>>>>>
>>>>>Regards,
>>>>>Asle
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>---------------------------------------------------------------------
>>>>
>>>>
>>>>        
>>>>
>>>>>To unsubscribe, e-mail:
>>>>>user-unsubscribe@ant.apache.org
>>>>>For additional commands, e-mail:
>>>>>user-help@ant.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>____________________________________________________
>>>>Sell on Yahoo! Auctions – no fees. Bid on great items.
>>>>http://auctions.yahoo.com/
>>>>
>>>>
>>>>
>>>>        
>>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>    
>>


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


Re: storing optional (ftp) task jar dependency under my project instead of under /ant/lib

Posted by Asle Pedersen <ap...@gmail.com>.
Ok, in that case alt.3 is not very attractive afterall. I don't know
if it is just me but I prefer do embed this type of behaviour in the
build.xml and project itself.

I have had similar problems with system environment variables in
particular charset encodings which need to be set outside of the
build.xml. Instead of just executing the build.xml this causes me to
have a shellscript to set the environment variables and execute the
build.xml

What I could do in this particular case is provide an install
mechanism (a target in the build.xml perhaps) for the ftp-task which
copies the commons-net-1.1.0.jar from the projects lib directory into
$HOME\.ant\lib. That way it would be fairly straightforward to use.

/A 


On 7/12/05, Peter Reilly <pe...@apache.org> wrote:
> Asle Pedersen wrote:
> 
> >I prefer alt.3 and try using taskdefs before without success. I did
> >try it again now also not successfully. Could you please supply me
> >with a complete working example?
> >
> >This is how my (non-working) build.xml looks like now:
> >(both .jar files are placed in the lib directory under the basedir)
> >
> ><project name="imweb" default="upload" basedir=".">
> >
> >       <taskdef name="ftp" classname="org.apache.tools.ant.taskdefs.optional.net.FTP">
> >        <classpath>
> >          <pathelement location="/lib/ant-commons-net.jar"/>
> >          <pathelement location="/lib/commons-net-1.1.0.jar"/>
> >        </classpath>
> >       </taskdef>
> >
> >       <target name="upload">
> >               <ftp server="..." userid="... password="..." depends="yes" verbose="yes">
> >                       <fileset dir="en" />
> >               </ftp>
> >       </target>
> ></project>
> >
> >Is it really necessary to place ant-commons-net in the classpath since
> >it is already under the ant/lib path? btw! I am using ant.1.6.5
> >
> >
> See the FAQ on classloading.
> Option number 3, as Ivan says, *requires" moving ant-commons-net.jar
> out of the ant lib directory to some place else, otherwise the
> ant-commons-net.jar gets
> loaded at ant startup time (sort of, it is in the startup classpath), and
> at this time (with this classpath) it cannot see the commons net classes
> so the task will not start.
> Peter
> 
> >Regards,
> >Asle
> >
> >
> >
> >On 7/12/05, Ivan Ivanov <ra...@yahoo.com> wrote:
> >
> >
> >>Asle,
> >>
> >>You have several other alternatives to keep your ant
> >>distribution clean of external libs:
> >>1) Put commons-net-1.1.0.jar in $HOME\.ant\lib (my
> >>favourite way)
> >>2) Place it an arbitrary directory say
> >>/path/to/thirdparty/jars and use -lib option of ant
> >>launching script.
> >>
> >>3) (Requires more coding and its benefits are
> >>doubtful). Move ant-commons-net.jar from $ANT_HOME/lib
> >>to some other folder and in your build script
> >><taskdef> ftp task like this:
> >><taskdef name="ftp" classname="...">
> >>  <classpath>
> >>    <pathelement
> >>location="/path/to/ant-commons-net.jar"/>
> >>    <pathelement location="/path/to/commons-net.jar"/>
> >>  </classpath>
> >></taskdef>
> >>
> >>Regards
> >>Ivan
> >>
> >>--- Asle Pedersen <ap...@gmail.com> wrote:
> >>
> >>
> >>
> >>>Is it possible to "embed" the ant ftp task in a
> >>>project. I would like
> >>>to just depend on a standard ant-installation to use
> >>>the ftp task and
> >>>have the commons-net-1.1.0.jar in my project instead
> >>>of under /ant/lib
> >>>which is suggested by the documentation. I have
> >>>tried different
> >>>methods to do this but none have worked so far. Any
> >>>suggestions?
> >>>
> >>>Regards,
> >>>Asle
> >>>
> >>>
> >>>
> >>>
> >>---------------------------------------------------------------------
> >>
> >>
> >>>To unsubscribe, e-mail:
> >>>user-unsubscribe@ant.apache.org
> >>>For additional commands, e-mail:
> >>>user-help@ant.apache.org
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>____________________________________________________
> >>Sell on Yahoo! Auctions – no fees. Bid on great items.
> >>http://auctions.yahoo.com/
> >>
> >>
> >>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
>

Re: storing optional (ftp) task jar dependency under my project instead of under /ant/lib

Posted by Peter Reilly <pe...@apache.org>.
Asle Pedersen wrote:

>I prefer alt.3 and try using taskdefs before without success. I did
>try it again now also not successfully. Could you please supply me
>with a complete working example?
>
>This is how my (non-working) build.xml looks like now:
>(both .jar files are placed in the lib directory under the basedir)
>
><project name="imweb" default="upload" basedir=".">
>
>	<taskdef name="ftp" classname="org.apache.tools.ant.taskdefs.optional.net.FTP">
>	 <classpath>
>	   <pathelement	location="/lib/ant-commons-net.jar"/>
>	   <pathelement location="/lib/commons-net-1.1.0.jar"/>
>	 </classpath>
>	</taskdef>	
>	
>	<target name="upload">
>		<ftp server="..." userid="... password="..." depends="yes" verbose="yes">		
>			<fileset dir="en" />
>		</ftp>
>	</target>
></project>
>
>Is it really necessary to place ant-commons-net in the classpath since
>it is already under the ant/lib path? btw! I am using ant.1.6.5
>  
>
See the FAQ on classloading.
Option number 3, as Ivan says, *requires" moving ant-commons-net.jar
out of the ant lib directory to some place else, otherwise the 
ant-commons-net.jar gets
loaded at ant startup time (sort of, it is in the startup classpath), and
at this time (with this classpath) it cannot see the commons net classes
so the task will not start.
Peter

>Regards,
>Asle
>
>
>
>On 7/12/05, Ivan Ivanov <ra...@yahoo.com> wrote:
>  
>
>>Asle,
>>
>>You have several other alternatives to keep your ant
>>distribution clean of external libs:
>>1) Put commons-net-1.1.0.jar in $HOME\.ant\lib (my
>>favourite way)
>>2) Place it an arbitrary directory say
>>/path/to/thirdparty/jars and use -lib option of ant
>>launching script.
>>
>>3) (Requires more coding and its benefits are
>>doubtful). Move ant-commons-net.jar from $ANT_HOME/lib
>>to some other folder and in your build script
>><taskdef> ftp task like this:
>><taskdef name="ftp" classname="...">
>>  <classpath>
>>    <pathelement
>>location="/path/to/ant-commons-net.jar"/>
>>    <pathelement location="/path/to/commons-net.jar"/>
>>  </classpath>
>></taskdef>
>>
>>Regards
>>Ivan
>>
>>--- Asle Pedersen <ap...@gmail.com> wrote:
>>
>>    
>>
>>>Is it possible to "embed" the ant ftp task in a
>>>project. I would like
>>>to just depend on a standard ant-installation to use
>>>the ftp task and
>>>have the commons-net-1.1.0.jar in my project instead
>>>of under /ant/lib
>>>which is suggested by the documentation. I have
>>>tried different
>>>methods to do this but none have worked so far. Any
>>>suggestions?
>>>
>>>Regards,
>>>Asle
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>    
>>
>>>To unsubscribe, e-mail:
>>>user-unsubscribe@ant.apache.org
>>>For additional commands, e-mail:
>>>user-help@ant.apache.org
>>>
>>>
>>>      
>>>
>>
>>
>>____________________________________________________
>>Sell on Yahoo! Auctions – no fees. Bid on great items.
>>http://auctions.yahoo.com/
>>
>>    
>>


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


Re: storing optional (ftp) task jar dependency under my project instead of under /ant/lib

Posted by Ivan Ivanov <ra...@yahoo.com>.
Asle,

--- Asle Pedersen <ap...@gmail.com> wrote:

> I prefer alt.3 and try using taskdefs before without
> success. I did
> try it again now also not successfully. Could you
> please supply me
> with a complete working example?
I've implemented this approach only once for <junit>,
because I was only curious and It is of no benefit of
any environment I work on. Let me just ask you why do
you insist on it.

I think you should change this:
> 	   <pathelement
> location="/lib/ant-commons-net.jar"/>
> 	   <pathelement
> location="/lib/commons-net-1.1.0.jar"/>

with:

<pathelement
location="${basedir}/lib/ant-commons-net.jar"/>
<pathelement
location="${basedir}/lib/commons-net-1.1.0.jar"/>

> Is it really necessary to place ant-commons-net in
> the classpath since
> it is already under the ant/lib path? btw! 
Yes, it is. It is the way Java classloaders work, not
an Ant restriction. <taskdef> uses a separate
classloader to load the jars related with the task
that is being defined. On the other hand, jars that
are in $ANT_HOME/lib are loader by another
classloader. So you can not have ant-commons-net
loader by the one and commons-net loader by the other.


> I am using ant.1.6.5
See [1] for a nicer explanation

Regards
Ivan

> 
> Regards,
> Asle
> 
[1]http://ant.apache.org/faq.html#delegating-classloader-1.6


		
____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.  
http://auctions.yahoo.com/

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


Re: storing optional (ftp) task jar dependency under my project instead of under /ant/lib

Posted by Asle Pedersen <ap...@gmail.com>.
I prefer alt.3 and try using taskdefs before without success. I did
try it again now also not successfully. Could you please supply me
with a complete working example?

This is how my (non-working) build.xml looks like now:
(both .jar files are placed in the lib directory under the basedir)

<project name="imweb" default="upload" basedir=".">

	<taskdef name="ftp" classname="org.apache.tools.ant.taskdefs.optional.net.FTP">
	 <classpath>
	   <pathelement	location="/lib/ant-commons-net.jar"/>
	   <pathelement location="/lib/commons-net-1.1.0.jar"/>
	 </classpath>
	</taskdef>	
	
	<target name="upload">
		<ftp server="..." userid="... password="..." depends="yes" verbose="yes">		
			<fileset dir="en" />
		</ftp>
	</target>
</project>

Is it really necessary to place ant-commons-net in the classpath since
it is already under the ant/lib path? btw! I am using ant.1.6.5

Regards,
Asle



On 7/12/05, Ivan Ivanov <ra...@yahoo.com> wrote:
> Asle,
> 
> You have several other alternatives to keep your ant
> distribution clean of external libs:
> 1) Put commons-net-1.1.0.jar in $HOME\.ant\lib (my
> favourite way)
> 2) Place it an arbitrary directory say
> /path/to/thirdparty/jars and use -lib option of ant
> launching script.
> 
> 3) (Requires more coding and its benefits are
> doubtful). Move ant-commons-net.jar from $ANT_HOME/lib
> to some other folder and in your build script
> <taskdef> ftp task like this:
> <taskdef name="ftp" classname="...">
>   <classpath>
>     <pathelement
> location="/path/to/ant-commons-net.jar"/>
>     <pathelement location="/path/to/commons-net.jar"/>
>   </classpath>
> </taskdef>
> 
> Regards
> Ivan
> 
> --- Asle Pedersen <ap...@gmail.com> wrote:
> 
> > Is it possible to "embed" the ant ftp task in a
> > project. I would like
> > to just depend on a standard ant-installation to use
> > the ftp task and
> > have the commons-net-1.1.0.jar in my project instead
> > of under /ant/lib
> > which is suggested by the documentation. I have
> > tried different
> > methods to do this but none have worked so far. Any
> > suggestions?
> >
> > Regards,
> > Asle
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> > user-help@ant.apache.org
> >
> >
> 
> 
> 
> 
> ____________________________________________________
> Sell on Yahoo! Auctions – no fees. Bid on great items.
> http://auctions.yahoo.com/
>

Re: storing optional (ftp) task jar dependency under my project instead of under /ant/lib

Posted by Ivan Ivanov <ra...@yahoo.com>.
Asle,

You have several other alternatives to keep your ant
distribution clean of external libs:
1) Put commons-net-1.1.0.jar in $HOME\.ant\lib (my
favourite way)
2) Place it an arbitrary directory say
/path/to/thirdparty/jars and use -lib option of ant
launching script.

3) (Requires more coding and its benefits are
doubtful). Move ant-commons-net.jar from $ANT_HOME/lib
to some other folder and in your build script
<taskdef> ftp task like this:
<taskdef name="ftp" classname="...">
  <classpath>
    <pathelement
location="/path/to/ant-commons-net.jar"/>
    <pathelement location="/path/to/commons-net.jar"/>
  </classpath>
</taskdef>

Regards
Ivan

--- Asle Pedersen <ap...@gmail.com> wrote:

> Is it possible to "embed" the ant ftp task in a
> project. I would like
> to just depend on a standard ant-installation to use
> the ftp task and
> have the commons-net-1.1.0.jar in my project instead
> of under /ant/lib
> which is suggested by the documentation. I have
> tried different
> methods to do this but none have worked so far. Any
> suggestions?
> 
> Regards,
> Asle
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



		
____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.  
http://auctions.yahoo.com/

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