ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikael Petterson (KI/EAB)" <mikael.petter...@ericsson.com>
Subject RE: make properites of data in file
Date Mon, 17 Oct 2005 10:17:26 GMT
Hi,

which version of rhino(js) and bsf do you use?

cheers,

//mikael

-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
Sent: den 17 oktober 2005 11:23
To: user@ant.apache.org
Subject: AW: make properites of data in file


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:mikael.petterson@ericsson.com] 
>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: 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


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


Mime
View raw message