The easiest way is defining the Ant properties and creating the 
product.attributes.
But you can parse that file and assign properties ... using your own task.

Quick hack (without any error handling). It parses the first line to get the 
meta data
and parses the second line for the data. After that it stores the values.


Jan

<project>

<scriptdef name="getProductInfos" language="javascript">
    <attribute name="prefix"/>
    <attribute name="file"/>
    <![CDATA[
        // imports
        importClass(Packages.org.apache.tools.ant.util.FileUtils);
     
        // constants
        splitChar = ":";

        // arguments
        prefix = attributes.get("prefix");
        file   = attributes.get("file");

        // read the file
        rdr = new java.io.FileReader(file);
        content = FileUtils.readFully(rdr);

        // split into metadata and content data
        lines = content.split( project.getProperty("line.separator") );
        header = lines[0];
        body = lines[1];

        // get the metadata
        metaData = header.split(splitChar);

        // get the content data and save as Ant properties
        contentData = body.split(splitChar);
        for (i=0; i<contentData.length; i++) {
            project.setNewProperty(prefix + "." + metaData[i], contentData[i]);
        }
    ]]>
</scriptdef>

<getProductInfos prefix="prod" file="product.attributes"/>
<echoproperties prefix="prod"/>

</project>


 

>-----Ursprüngliche Nachricht-----
>Von: Mikael Petterson (KI/EAB) [mailto:[EMAIL PROTECTED] 
>Gesendet: Montag, 17. Oktober 2005 10:38
>An: user@ant.apache.org
>Betreff: make properites of data in file
>
>Hi,
>
>I have the following properties in my build.xml:
>
><property name="target" value="xxx"/>
><property name="productnumber" value="yyy"/> <property 
>name="productrevision" value="zzz"/>
>
>In a file called product.attribues I have the following information:
>
>TARGET:PRODUCT_NUMBER:PRODUCT_REVISION
>jvm:CXC1327714/22:R1A01
>
>Is it possible to assign ant properties with the values in my files? 
>
>cheers,
>
>//mikael
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED] For 
>additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to