Where is the problem?
<project>
<taskdef/>
<propertyread/>
<target>
<echoproperties/>
</target>
</project>
in that order should work.
Jan
>-----Ursprüngliche Nachricht-----
>Von: Mikael Petterson (KI/EAB) [mailto:[EMAIL PROTECTED]
>Gesendet: Dienstag, 18. Oktober 2005 12:50
>An: [email protected]
>Betreff: set property values using my own task
>
>Hi,
>
>The purose of my task is to set the values for properties
>arch, product_number and product_revision.
>The information is stored in a file called
>'product.attributes'. I need to assign the properties the
>values ( line two) in the product.attributes file and then use
>the property values in target, prepare-product-info. Is it possible ?
>Any suggestions?
>
>cheers,
>
>//mikael
>
>
>This is the content of product.attributes:
>
>TARGET:PRODUCT_NUMBER:PRODUCT_REVISION
>jvm:CXC1327714/22:R1A01
>default:BAD_TARGET:R1A01
>
>
>build.xml
>=======
>
><project ........>
>......
><property name="arch" value="jvm"/>
><property name="product_number" value="BAD000"/>
><property name="product_revision" value="P0"/>
>
>.........
>
> <target name="product.attributes">
>
> <taskdef name="propertyread"
> classname="se.mycompany.PropertyReadTask"/>
> <propertyread prefix="prod"
>file="product.attributes" delimiter=":"/>
> <echoproperties prefix="prod"/>
> </target>
>
> <target name="prepare-product-info"
> depends="propertyread"
> description="Prepare product information.">
> <echo>Product name : ${name}</echo>
> <echo>Product number : ${product_number}</echo>
> <echo>Product rev : ${product_revision}</echo>
> <exec executable="cleartool"
> outputproperty="view">
> <arg line="pwv -short"/>
> </exec>
> <tstamp>
> <format property="datetime"
> pattern="yyyy-MM-dd HH:mm:ss z"/>
> </tstamp>
>
> <property name="product.attrs.line1"
> value="${user.dir} ${name} ${arch} ${view}"/>
> <property name="product.attrs.line2"
> value="${product_number} ${product_revision}
>${datetime} ${identifier}"/> </target>
>
></project>
>
>PropertyReadTask file
>================
>public class PropertyReadTask extends org.apache.tools.ant.Task{
>
> private String prefix;
> private String file;
> private String delimiter;
>
> public void execute() throws BuildException {
> if (prefix==null || file==null) {
> throw new BuildException("prefix and file must be set");
> }
> try{
> // read the file
> Reader rdr = new java.io.FileReader(file);
> String content = FileUtils.readFully(rdr);
> // split into metadata and content data
> String lines[] = content.split(
>getProject().getProperty("line.separator") );
> String h1eader = lines[0];
> String body = lines[1];
>
> // get the metadata
> String metaData[] = header.split(delimiter);
>
> // get the content data and save as Ant properties
> String contentData[] = body.split(delimiter);
> for (int i=0; i<contentData.length; i++) {
> getProject().setNewProperty(prefix + "." +
>metaData[i], contentData[i]);
> }
>
> }catch(Exception e){
> throw new BuildException("Something happened");
> }
>
> }
>
>
> public void setDelimiter(String delimiter){
> this.delimiter = delimiter;
> }
>
> public void setFile(String file){
> this.file = file;
> }
>
> public void setPrefix(String prefix){
> this.prefix = prefix;
> }
>
>
>
>}
>
>
>---------------------------------------------------------------------
>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]