ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: how to copy a bunch of *unrelated* files ?
Date Thu, 28 Mar 2002 20:20:11 GMT
Just replace

<path id=" ext_libs">
  <pathelement
location="${user.home}/Developer/Java/jaf-1.0.1/lib/activation.jar" />
  <pathelement
location="${user.home}/Developer/Java/javamail-1.2/lib/mailapi.jar" />
</path>
...

by

<fileset id="ext_libs.files" dir="${user.home}/Developer/Java">
  <patternset>
    <include name="${user.home}/Developer/Java/jaf-1.0.1/lib/activation.jar"
/>
    <include name="${user.home}/Developer/Java/javamail-1.2/lib/mailapi.jar"
/>
  </patternset>
</fileset>

<path id="ext_libs">
  <fileset refid="ID1" />
</path>

<javac srcdir="${src.java}" destdir="${build.classes}"
	<classpath refid="ext_libs"/>
	<patternset refid="non.test.source_files"/>
</javac>

<copy todir="${dist.lib}">
  <fileset refid="ext_libs.files" />
</copy>

Not tested. I agree it's not very elegant. Best I could think off quickly
before Diane gives you an elegant solution ;-)  --DD


 -----Original Message-----
From: 	Zart Colwing [mailto:zartc@wanadoo.fr] 
Sent:	Thursday, March 28, 2002 12:33 PM
To:	ant-user@jakarta.apache.org
Subject:	how to copy a bunch of *unrelated* files ?

It may seams overly simple but curiously it is not, or I'm really 
stupid ;)

I want to copy a list of file (jar files), each one originating from its 
own directory (thus I can't use a filseset), into the same directory 
inside my distribution directory (the lib directory of my application).

Ideally I'd like to reuse a <path> structure I have defined to compile 
and run the application so that I'm sure to never forget any library 
critical library in the future.

here is a bit of xml to help make the example clear:

<!-- Define ${ext_libs} -->
<!-- The list of jar files requiered to compile and run the 
application -->
<!-- all these files must be copied to the ${dist}/lib directory on 
deployment -->
<path id="ext_libs">
	<pathelement 
location="${user.home}/Developer/Java/jaf-1.0.1/lib/activation.jar"/>
	<pathelement 
location="${user.home}/Developer/Java/javamail-1.2/lib/mailapi.jar"/>
	<pathelement 
location="${user.home}/Developer/Java/javamail-1.2/lib/smtp.jar"/>
	<pathelement 
location="${user.home}/Developer/Java/regex4j/regex4j.jar"/>
	<pathelement 
location="${user.home}/Developer/Java/log4j-1.2beta4/dist/lib/log4j-1.2beta4
.
jar"/>
</path>

I use the ${ext_libs} path stuctures in a javac task like this:

<javac srcdir="${src.java}" destdir="${build.classes}"
	<classpath refid="ext_libs"/>
	<patternset refid="non.test.source_files"/>
</javac>

Ok, now the tricky part: I wanted to reuse the ${ext_libs} path to copy 
all the required libraries into the lib directory of my application. 
Naively (again !) I tried:

<copy todir="${dist.lib}">
	<path refid="ext_libs"/>
</copy>

Unfortunately the copy task does not support a nested <path> element !  
Ok I thought, lets try to create a fileset that reuse this path. Alas, 
while is is entirely possible to create a path from a fileset, the 
inverse is impossible !  This matter of fact is quite understandable 
since a path is a higher level stucture than a fileset (A path structure 
is a more general abstraction that can embed a filseset).

Now the questions:
1- How do I elegantly solve my problem with the Ant tool available 
today, using a single copy task that reuse the ${ext_libs} path ?
2- Isn't it flawed that so many Ant tool use the more restrictive 
fileset structure where they could instead use the more general path 
structure ?

ZC.


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

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


Mime
View raw message