You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by caleysoldman <ta...@yahoo.com> on 2007/06/08 17:41:21 UTC

can filesets be stored in a properties file?


hi folx,

is it possible to use the refid of a fileset that is stored in a properties
file? if so, how??

i am new to ant and to java. i have successfully created a build that uses
one of two properties files based on a variable that is passed at the
command line via -D option. now i would like to move my fileset to the
properties files, but when i do, the refid no longer works.

thanks...
-- 
View this message in context: http://www.nabble.com/can-filesets-be-stored-in-a-properties-file--tf3890587.html#a11028955
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: can filesets be stored in a properties file?

Posted by Matt Benson <gu...@yahoo.com>.
Oh, is THAT what he meant?  :)

well, whatever...

--- Gilbert Rebhan <an...@schillbaer.de> wrote:

> Hi,
> 
> caleysoldman wrote:
> 
> [ ...]
> > :arguing:
> > 
> > regardless, what i did was create a working build
> ...all i really need to
> > understand is how to move the fileset to an
> external file that will then be
> > used based on the DBMS property which value is
> passed at the command line.
> > thanks in advance for your help ant folx!
> [ ... ]
> 
> if that's all you need, you can use <echo> task
> combined with the 
> ${toString:NameOfYourID} property, i.e.
> 
> <fileset id="myfileset" dir="C:/Test"
> includes="**/*.xml"/>
> 
> and later
> 
> <echo
> file="fileset.txt">${toString:myfileset}</echo>
> 
> write the files in a separated list to a file.
> 
> if you need another format, i.e
> 
> file1
> file2
> file3
> ...
> 
> 
> you can go via antcontrib =
> http://ant-contrib.sourceforge.net/
> 
> pseudocode, see examples in the manual of antcontrib
> =
>
http://ant-contrib.sourceforge.net/tasks/tasks/for.html
> 
> <for param="file">
> <path>
> your fileset
> </path>
> <sequential>
> echo @{file}${line.separator}
> ...
> 
> 
> Regards, Gilbert
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



       
____________________________________________________________________________________
Sick sense of humor? Visit Yahoo! TV's 
Comedy with an Edge to see what's on, when. 
http://tv.yahoo.com/collections/222

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


Re: can filesets be stored in a properties file?

Posted by Gilbert Rebhan <an...@schillbaer.de>.
Hi,

caleysoldman wrote:

[ ...]
> :arguing:
> 
> regardless, what i did was create a working build ...all i really need to
> understand is how to move the fileset to an external file that will then be
> used based on the DBMS property which value is passed at the command line.
> thanks in advance for your help ant folx!
[ ... ]

if that's all you need, you can use <echo> task combined with the 
${toString:NameOfYourID} property, i.e.

<fileset id="myfileset" dir="C:/Test" includes="**/*.xml"/>

and later

<echo file="fileset.txt">${toString:myfileset}</echo>

write the files in a separated list to a file.

if you need another format, i.e

file1
file2
file3
...


you can go via antcontrib =
http://ant-contrib.sourceforge.net/

pseudocode, see examples in the manual of antcontrib =
http://ant-contrib.sourceforge.net/tasks/tasks/for.html

<for param="file">
<path>
your fileset
</path>
<sequential>
echo @{file}${line.separator}
...


Regards, Gilbert




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


Re: can filesets be stored in a properties file?

Posted by Matt Benson <gu...@yahoo.com>.
--- caleysoldman <ta...@yahoo.com> wrote:

> 
> hi matt, thanks for your reply...here you are ant
> folx:
> 
> my requirement is to produce sql using ant. i am
> enjoined not to use
> velocity, groovy, or anything but ant. 
> 
> as such, what i am trying to replicate is shell
> script logic because those
> are my marching orders. i mention this because i'm
> sure real application
> developers will object to this egregious misuse of
> ant... 
> 
Thanks for clarifying all that up front.  :)

> :arguing:
> 
> regardless, what i did was create a working build
> ...all i really need to
> understand is how to move the fileset to an external
> file that will then be
> used based on the DBMS property which value is
> passed at the command line.
> thanks in advance for your help ant folx!
> 

If you know that you only have a finite number of
filesets, here typicalTableSQL and typicalTabStorage,
it shouldn't be too difficult.  You should be able to
add some properties to generic.properties or another
properties file to handle what you need.  Here's what
I would probably do:

#new file e.g. "filesets.properties":
typicalTableSQL.dir=sql_def/tables
typicalTableSQL.includes=**/*.tmplt
typicalTableSQL.excludes=a.tmplt,b.tmplt,${EXCLUDE01}.tmplt
typicalTabStorage.dir=sql_def/storage
typicalTabStorage.includes=${DBMS}_typtab_storage.tmplt
#end

Then add to your buildfile, after you've loaded
generic.properties:

<property file="filesets.properties" />
<macrodef name="createFileset">
  <attribute name="assignid" />
  <sequential>
    <!-- default includes and excludes -->
    <property name="@{assignid}.includes" value="**/*"
/>
    <property name="@{assignid}.excludes" value="" />
    <fileset id="@{assignid}" dir="${@{assignid}.dir}"
                 includes="${@{assignid}.includes}"
                 excludes="${@{assignid}.excludes}" />
  </sequential>
</macrodef>

<createFileset assignid="typicalTableSQL" />
<createFileset assignid="typicalTabStorage" />

... finally, of course, remove your old fileset
definitions.

Good luck,
Matt

[SNIP]


       
____________________________________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php

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


Re: can filesets be stored in a properties file?

Posted by caleysoldman <ta...@yahoo.com>.
hi matt, thanks for your reply...here you are ant folx:

my requirement is to produce sql using ant. i am enjoined not to use
velocity, groovy, or anything but ant. 

as such, what i am trying to replicate is shell script logic because those
are my marching orders. i mention this because i'm sure real application
developers will object to this egregious misuse of ant... 

:arguing:

regardless, what i did was create a working build ...all i really need to
understand is how to move the fileset to an external file that will then be
used based on the DBMS property which value is passed at the command line.
thanks in advance for your help ant folx!

<?xml version="1.0" ?>

<!-- #######################################################################
-->
<!-- Project Line               -->
<!-- #######################################################################
-->
<project default="createTableSQL">

 <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
 <taskdef resource="customtasks.properties"/>
 <typedef resource="customtypes.properties"/>

 <property file="${basedir}/generic.properties" />
 <property name="DBMS" value="NOT_SET" />

<!-- ############################################################# -->
<!-- Target to loop through the files -->
<!-- ############################################################# -->
 <target name="createTableSQL" depends="commandline">

 <echo>
  Producing SQL for DBMS ${DBMS}
 </echo>

<!-- ############################################################# -->
<!-- Outer for loop for the typical tables -->
<!-- ############################################################# -->
  <for param="tabfiles">
   <fileset refid="typicalTableSQL"/>
   <sequential>
    <processfile file="@{tabfiles}"/>

<!-- ############################################################# -->
<!-- Nested for loop for the typical storage -->
<!-- ############################################################# -->
     <for param="storage">
      <fileset refid="typicalTabStorage"/>
       <sequential>
        <processfile file="@{storage}"/>
       </sequential>
     </for>

   </sequential>
  </for>

 </target>

<!-- ############################################################# -->
<!-- MACRO to process the files -->
<!-- ############################################################# -->
 <macrodef name="processfile">
  <attribute name="file"/>
   <sequential>
    <echo>Process @{file}</echo>
     <concat destfile="test.txt" append="true">
      <fileset file="@{file}"/>
       <filterchain>
        <expandproperties/>
       </filterchain>
     </concat>
   </sequential>
 </macrodef>

<!-- ############################################################## -->
<!-- Validate Command Line Args -->
<!-- ############################################################## -->
 <target name="commandline">
  <if>
   <equals arg1="ora" arg2="${DBMS}" />
    <then>
     <property file="${basedir}/${DBMS}.properties" />
    </then>
  <elseif>
   <equals arg1="db2" arg2="${DBMS}" />
    <then>
     <property file="${basedir}/${DBMS}.properties" />
    </then>
  </elseif>
  <else>
   <fail>
    ERROR: Missing Command Line Property Varialbe DBMS: ${DBMS}.
   </fail>
  </else>
  </if>
 </target>

<!-- ############################################################# -->
<!-- Fileset for typical tables -->
<!-- ############################################################# -->
 <fileset
  id="typicalTableSQL"
  dir="sql_def/tables" >
  <include name="**/*.tmplt"/>
  <exclude name="a.tmplt"/>
  <exclude name="b.tmplt"/>
  <exclude name="${EXCLUDE01}.tmplt"/>
 </fileset>

<!-- ############################################################# -->
<!-- Fileset for typical table storage -->
<!-- ############################################################# -->
 <fileset
  id="typicalTabStorage"
  dir="sql_def/storage" >
  <include name="${DBMS}_typtab_storage.tmplt"/>
 </fileset>

</project>



-- 
View this message in context: http://www.nabble.com/can-filesets-be-stored-in-a-properties-file--tf3890587.html#a11030923
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: can filesets be stored in a properties file?

Posted by Matt Benson <gu...@yahoo.com>.
Show us an example of what you're trying to do.

-Matt

--- caleysoldman <ta...@yahoo.com> wrote:

> 
> 
> hi folx,
> 
> is it possible to use the refid of a fileset that is
> stored in a properties
> file? if so, how??
> 
> i am new to ant and to java. i have successfully
> created a build that uses
> one of two properties files based on a variable that
> is passed at the
> command line via -D option. now i would like to move
> my fileset to the
> properties files, but when i do, the refid no longer
> works.
> 
> thanks...
> -- 
> View this message in context:
>
http://www.nabble.com/can-filesets-be-stored-in-a-properties-file--tf3890587.html#a11028955
> Sent from the Ant - Users mailing list archive at
> Nabble.com.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

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