You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Lewis Tsao <lt...@talk21.com> on 2010/06/23 10:18:40 UTC

Setting multiple outputproperties

Hi all,

In one of my build setups, I need to run a program first which produces some output. From this output I need to get multiple pieces of information to be used in later build steps:

For example:

<execute step1prog ...../>

step1prog produces lines of the form

something
blah blah info1 blah blah
more blah...
di blah di blah info2 di blah
more something

later on in my build steps I will need to do somelike

<execute step2prog -Dxxx=info1>

<execute step3prog -Dyyy=info2>

Is there a clever way of doing this, short of sending output from step1prog to a file and parsing the file twice to get the 2 pieces of info.

I still have to learn how to tease info1 and info2 out of the output yet, but that's another story.

Many thanks

Lewis



      


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


Re: Setting multiple outputproperties

Posted by Michael Ludwig <mi...@gmx.de>.
Lewis Tsao schrieb am 23.06.2010 um 08:18 (+0000):

> In one of my build setups, I need to run a program first which
> produces some output. From this output I need to get multiple pieces
> of information to be used in later build steps:
> 
> For example:
> 
> <execute step1prog ...../>
> 
> step1prog produces lines of the form
> 
> something
> blah blah info1 blah blah
> more blah...
> di blah di blah info2 di blah
> more something
> 
> later on in my build steps I will need to do somelike
> 
> <execute step2prog -Dxxx=info1>
> 
> <execute step3prog -Dyyy=info2>
> 
> Is there a clever way of doing this, short of sending output from
> step1prog to a file and parsing the file twice to get the 2 pieces of
> info.

At any rate, you should be able to do it in one pass.

> I still have to learn how to tease info1 and info2 out of the output
> yet, but that's another story.

On the contrary, I think this is what this is all about. Can you modify
step1prog to output relevant information in a structured manner, such as
to a property file, or to XML?

If not, you could try some regex hacking such as in this example:

<project>
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
  <exec executable="ipconfig" outputproperty="ipconfig-out"/>
  <propertyregex property="ip-number" input="${ipconfig-out}"
    regexp="\d+\.\d+\.\d+\.\d+" select="\0" global="yes" />
  <echo message="${ip-number}"/>
</project>

But <propertyregex> does not appear to support multiple matches, so this
is not exactly an elegant solution.

-- 
Michael Ludwig

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


AW: Setting multiple outputproperties

Posted by Ja...@rzf.fin-nrw.de.
I would write a custom task which analyses the data and stores a bunch of properties.
Depending on the step1prog the data-source would be a property or a file.

public class Step1ProgAnalyseTask extends Task {
    private File data; // setter
    private String prefix; // setter
    public void execute() {
        Map<String,String> data = analyse(data); 
        for(String key : data.keys) {
            getProject().setNewProperty(prefix + key, data.get(key));
        }
    }
}


Jan

>-----Ursprüngliche Nachricht-----
>Von: Lewis Tsao [mailto:ltsao@talk21.com] 
>Gesendet: Mittwoch, 23. Juni 2010 10:19
>An: user@ant.apache.org
>Betreff: Setting multiple outputproperties
>
>Hi all,
>
>In one of my build setups, I need to run a program first which 
>produces some output. From this output I need to get multiple 
>pieces of information to be used in later build steps:
>
>For example:
>
><execute step1prog ...../>
>
>step1prog produces lines of the form
>
>something
>blah blah info1 blah blah
>more blah...
>di blah di blah info2 di blah
>more something
>
>later on in my build steps I will need to do somelike
>
><execute step2prog -Dxxx=info1>
>
><execute step3prog -Dyyy=info2>
>
>Is there a clever way of doing this, short of sending output 
>from step1prog to a file and parsing the file twice to get the 
>2 pieces of info.
>
>I still have to learn how to tease info1 and info2 out of the 
>output yet, but that's another story.
>
>Many thanks
>
>Lewis
>
>
>
>      
>
>
>---------------------------------------------------------------------
>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