You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "KARR, DAVID (ATTSI)" <dk...@att.com> on 2010/10/13 22:04:48 UTC

Proper way to translate list of jars from properties file into classpath

I have a property defined in my properties file that specifies a list of
jar files associated with a particular framework.  I'll need to
reference all of those jars any time I reference one of them, so I put
them in a single property.

It currently looks like this:

cxf-patches	= ${lib}/cxf-xjc-boolean-2.3.0.jar,\
		  ${lib}/cxf-xjc-bug671-2.3.0.jar,\
		  ${lib}/cxf-xjc-dv-2.3.0.jar,\
		  ${lib}/cxf-xjc-ts-2.3.0.jar

Where I've defined "lib" in my build.xml before this file is referenced
as "${basedir}/lib".

At this point, I'm not certain of the elements that I need to get these
jars properly referenced in a top-level path element so I can reference
it as the classpath for javac.  I imagine it involves using the
"filelist" element.

I tried this:

    <filelist id="cxfXjcPatch.jars.list" files="${cxf-patches}"/>

Then:

	<path id="build.classpath">
         ...
   	   <filelist refid="cxfXjcPatch.jars.list"/>
         ...
      </path>

This doesn't produce anything really useful.  It produces very odd
results in the final classpath.  I'm not going to bother listing it,
because I'm sure I'm doing something basically wrong here.


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


RE: Proper way to translate list of jars from properties file into classpath

Posted by "Moore, Kent" <Ke...@fisglobal.com>.
We define each reference in a single line of build.properties, then in
build.xml do an amalgamation of the references into different
patternsets which have different meanings. 

That gives us the flexibility to use some references in the build time
classpath, but not include them in the war/ear, and the flexibility to
include references in the war/ear which are not part of the build time
classpath.

Sample script attached, hope it helps.


-----Original Message-----
From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com] 
Sent: Wednesday, October 13, 2010 4:05 PM
To: Ant Users List
Subject: Proper way to translate list of jars from properties file into
classpath

I have a property defined in my properties file that specifies a list of
jar files associated with a particular framework.  I'll need to
reference all of those jars any time I reference one of them, so I put
them in a single property.

It currently looks like this:

cxf-patches	= ${lib}/cxf-xjc-boolean-2.3.0.jar,\
		  ${lib}/cxf-xjc-bug671-2.3.0.jar,\
		  ${lib}/cxf-xjc-dv-2.3.0.jar,\
		  ${lib}/cxf-xjc-ts-2.3.0.jar

Where I've defined "lib" in my build.xml before this file is referenced
as "${basedir}/lib".

At this point, I'm not certain of the elements that I need to get these
jars properly referenced in a top-level path element so I can reference
it as the classpath for javac.  I imagine it involves using the
"filelist" element.

I tried this:

    <filelist id="cxfXjcPatch.jars.list" files="${cxf-patches}"/>

Then:

	<path id="build.classpath">
         ...
   	   <filelist refid="cxfXjcPatch.jars.list"/>
         ...
      </path>

This doesn't produce anything really useful.  It produces very odd
results in the final classpath.  I'm not going to bother listing it,
because I'm sure I'm doing something basically wrong here.


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

_____________

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
_____________

RE: Proper way to translate list of jars from properties file into classpath

Posted by "Bailey, Darragh" <db...@hp.com>.
> -----Original Message-----
> From: KARR, DAVID (ATTSI) [mailto:dk068x@att.com] 
> Sent: 13 October 2010 21:05
> To: Ant Users List
> Subject: Proper way to translate list of jars from properties 
> file into classpath
> 
> I have a property defined in my properties file that 
> specifies a list of
> jar files associated with a particular framework.  I'll need to
> reference all of those jars any time I reference one of them, so I put
> them in a single property.
> 
> It currently looks like this:
> 
> cxf-patches	= ${lib}/cxf-xjc-boolean-2.3.0.jar,\
> 		  ${lib}/cxf-xjc-bug671-2.3.0.jar,\
> 		  ${lib}/cxf-xjc-dv-2.3.0.jar,\
> 		  ${lib}/cxf-xjc-ts-2.3.0.jar
> 
> Where I've defined "lib" in my build.xml before this file is 
> referenced
> as "${basedir}/lib".
> 
> At this point, I'm not certain of the elements that I need to 
> get these
> jars properly referenced in a top-level path element so I can 
> reference
> it as the classpath for javac.  I imagine it involves using the
> "filelist" element.
> 
> I tried this:
> 
>     <filelist id="cxfXjcPatch.jars.list" files="${cxf-patches}"/>
> 
> Then:
> 
> 	<path id="build.classpath">
>          ...
>    	   <filelist refid="cxfXjcPatch.jars.list"/>
>          ...
>       </path>
> 
> This doesn't produce anything really useful.  It produces very odd
> results in the final classpath.  I'm not going to bother listing it,
> because I'm sure I'm doing something basically wrong here.

Try striping the ${lib}/ reference off the paths to the jar files and use it as the directory for the filelist.

i.e. build.properties
cxf-patches	= cxf-xjc-boolean-2.3.0.jar,\
		  cxf-xjc-bug671-2.3.0.jar,\
		  cxf-xjc-dv-2.3.0.jar,\
		  cxf-xjc-ts-2.3.0.jar

build.xml
<project name="test" default="dist" basedir="." >
  <loadproperties srcFile="build.properties" />
  <property name="lib" location="${basedir}/lib" />

  <target name="dist" >
    <filelist id="cxfXjcPatch.jars.list" dir="${lib}" files="${cxf-patches}" />
    <path id="build.classpath">
      <filelist refid="cxfXjcPatch.jars.list"/>
    </path>
    <echo message="${toString:build.classpath}" />
  </target>

</project>

Produces the following when run for me:
[echo] /tmp/ant/lib/cxf-xjc-boolean-2.3.0.jar:/tmp/ant/lib/cxf-xjc-bug671-2.3.0.jar:/tmp/ant/lib/cxf-xjc-dv-2.3.0.jar:/tmp/ant/lib/cxf-xjc-ts-2.3.0.jar


Perhaps it was that you were trying to use filelist without setting the directory and placing that into the property that you were passing to it?

--
Regards,
Darragh Bailey



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


Re: Proper way to translate list of jars from properties file into classpath

Posted by Antoine Levy-Lambert <an...@gmx.de>.
  On 10/14/2010 5:09 PM, KARR, DAVID (ATTSI) wrote:
>> -----Original Message-----
>> From: KARR, DAVID (ATTSI)
>> Sent: Wednesday, October 13, 2010 1:05 PM
>> To: Ant Users List
>> Subject: Proper way to translate list of jars from properties file
> into
>> classpath
>>
>> I have a property defined in my properties file that specifies a list
>> of
>> jar files associated with a particular framework.  I'll need to
>> reference all of those jars any time I reference one of them, so I put
>> them in a single property.
>>
>> It currently looks like this:
>>
>> cxf-patches	= ${lib}/cxf-xjc-boolean-2.3.0.jar,\
>> 		  ${lib}/cxf-xjc-bug671-2.3.0.jar,\
>> 		  ${lib}/cxf-xjc-dv-2.3.0.jar,\
>> 		  ${lib}/cxf-xjc-ts-2.3.0.jar
>>
>> Where I've defined "lib" in my build.xml before this file is
>
> because I'm sure I'm doing something basically wrong here.
> At this point, I've gotten to the point where I can define two
> properties for each "grouped" resource, a "dir" and a "list" (where each
> list entry just has a file name, not a path).  I then define the
> "filelist" in the "path" element, specifying both properties.  That
> works.  I wish I could specify a single list property and reference that
> directly, and have Ant figure it out.
What you do normally in ant linguo is :

<fileset id="cxf-patches.fs" dir="${lib}">
<include name="cxf-xjc-boolean-2.3.0.jar"/>
<include name="cxf-xjc-bug671-2.3.0.jar"/>
<include name="cxf-xjc-dv-2.3.0.jar"/>
<include name="cxf-xjc-ts-2.3.0.jar"/>
</fileset>

you can then reference this construct like that

<path id="cxf-patches.cp">
<fileset refid="cxf-patches.fs"/>
</path>

A path can be used by any ant task which accepts paths, like <javac/>. 
The <pathconvert/> task can convert the path to a property using any 
separator you like.

Regards,

Antoine



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


RE: Proper way to translate list of jars from properties file into classpath

Posted by "KARR, DAVID (ATTSI)" <dk...@att.com>.
> -----Original Message-----
> From: KARR, DAVID (ATTSI)
> Sent: Wednesday, October 13, 2010 1:05 PM
> To: Ant Users List
> Subject: Proper way to translate list of jars from properties file
into
> classpath
> 
> I have a property defined in my properties file that specifies a list
> of
> jar files associated with a particular framework.  I'll need to
> reference all of those jars any time I reference one of them, so I put
> them in a single property.
> 
> It currently looks like this:
> 
> cxf-patches	= ${lib}/cxf-xjc-boolean-2.3.0.jar,\
> 		  ${lib}/cxf-xjc-bug671-2.3.0.jar,\
> 		  ${lib}/cxf-xjc-dv-2.3.0.jar,\
> 		  ${lib}/cxf-xjc-ts-2.3.0.jar
> 
> Where I've defined "lib" in my build.xml before this file is
referenced
> as "${basedir}/lib".
> 
> At this point, I'm not certain of the elements that I need to get
these
> jars properly referenced in a top-level path element so I can
reference
> it as the classpath for javac.  I imagine it involves using the
> "filelist" element.
> 
> I tried this:
> 
>     <filelist id="cxfXjcPatch.jars.list" files="${cxf-patches}"/>
> 
> Then:
> 
> 	<path id="build.classpath">
>          ...
>    	   <filelist refid="cxfXjcPatch.jars.list"/>
>          ...
>       </path>
> 
> This doesn't produce anything really useful.  It produces very odd
> results in the final classpath.  I'm not going to bother listing it,
> because I'm sure I'm doing something basically wrong here.

At this point, I've gotten to the point where I can define two
properties for each "grouped" resource, a "dir" and a "list" (where each
list entry just has a file name, not a path).  I then define the
"filelist" in the "path" element, specifying both properties.  That
works.  I wish I could specify a single list property and reference that
directly, and have Ant figure it out.

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