|
I have tried a few things today and still can't figure this out. I have a properties file with a setting of say test=successful and I want ant to check the property test to make sure it is set to successful before going on. How do I do this?
|
|
> I have tried a few things today and still can't figure this out. I have a > properties file with a setting of say test=successful and I want ant to > check the property test to make sure it is set to successful before going > on. How do I do this? see manual <condition>, f.e. = <condition property="allOK"> <equals arg1="${test}" arg2="successful"/> </condition> and later on = <target name="whatever" if="allOK"> ... </target> or the other way around <target name="whatever" unless="allOK"> ... </target> Regards, Gilbert --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
> <target name="whatever" if="allOK">
> <target name="whatever" unless="allOK"> But dont forget: <target if|unless> checks whether a property with the given name is set/not-set. <property name="foo" value="true"/> <target name="foo" unless="foo"> <echo>I will be executed</echo> </target> <property name="bar" value="false"/> <target name="bar" if="bar"> <echo>I will be executed</echo> </target> Jan --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by jpyork
This is a 2 step process. First you need to also create a conditional property based on the value of the property test. Then you can use that conditional property in target elements to conditionalize their execution. For instance
Step 1: <condition name="conditionOK"> <equals arg1="${test}" arg2="successful" </condition> Step 2: <target name="conditional_target" if=conditionOK> ... your target elements </target> ________________________________ From: jpyork [mailto:[hidden email]] Sent: Wed 1/23/2008 15:50 To: [hidden email] Subject: Checking a property with ant I have tried a few things today and still can't figure this out. I have a properties file with a setting of say test=successful and I want ant to check the property test to make sure it is set to successful before going on. How do I do this? -- View this message in context: http://www.nabble.com/Checking-a-property-with-ant-tp15051347p15051347.html Sent from the Ant - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
Alternativly use if-Task of antcontrib to do it in one step.
-- Jürgen Knuplesch www.icongmbh.de icon Systemhaus GmbH Tel. +49 711 806098-275 Sophienstraße 40 D-70178 Stuttgart Fax. +49 711 806098-299 Geschäftsführer: Uwe Seltmann HRB Stuttgart 17655 USt-IdNr.: DE 811944121 -----Ursprüngliche Nachricht----- Von: Barry Andreasen [mailto:[hidden email]] Gesendet: Donnerstag, 24. Januar 2008 10:45 An: [hidden email] Betreff: RE: Checking a property with ant This is a 2 step process. First you need to also create a conditional property based on the value of the property test. Then you can use that conditional property in target elements to conditionalize their execution. For instance Step 1: <condition name="conditionOK"> <equals arg1="${test}" arg2="successful" </condition> Step 2: <target name="conditional_target" if=conditionOK> ... your target elements </target> ________________________________ From: jpyork [mailto:[hidden email]] Sent: Wed 1/23/2008 15:50 To: [hidden email] Subject: Checking a property with ant I have tried a few things today and still can't figure this out. I have a properties file with a setting of say test=successful and I want ant to check the property test to make sure it is set to successful before going on. How do I do this? -- View this message in context: http://www.nabble.com/Checking-a-property-with-ant-tp15051347p15051347.html Sent from the Ant - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Jan.Materne
[hidden email] schrieb: > But dont forget: <target if|unless> checks whether a property with > the given name is set/not-set. therefore in my example the property thats' used afterwards with target if|unless is set via condition + equals ... ;-) > <property name="foo" value="true"/> > <target name="foo" unless="foo"> > <echo>I will be executed</echo> > </target> > > <property name="bar" value="false"/> > <target name="bar" if="bar"> > <echo>I will be executed</echo> > </target> so afterwards you're able to react if| unless that property is set after your gusto Regards, Gilbert --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by jpyork
This is what I have:
<condition property="buildfailed"> <equals arg1="${buildresults}" arg2="failed"/> </condition> <target name="buildresults" unless="buildfailed"> <fail message="Check deploy script for error" /> </target> If I am understanding this correctly then, the above should reference the buildresults property that is held in a property file and if it is set to failed...the script should fail. The issue is that when the buildresults is set to successful, the build still fails. Anyone see what I am doing wrong?
|
|
> <condition property="buildfailed"> > <equals arg1="${buildresults}" arg2="failed"/> > </condition> > > <target name="buildresults" unless="buildfailed"> > <fail message="Check deploy script for error" /> > </target> > > If I am understanding this correctly then, the above should reference the > buildresults property that is held in a property file and if it is set to > failed...the script should fail. The issue is that when the buildresults is > set to successful, the build still fails. > > Anyone see what I am doing wrong? your condition is right, you check whether your ${buildresults} property (set in a property file or otherwise) has the value "failed" and if yes the property ${buildfailed} is set. but = <target name="buildresults" unless="buildfailed"> means = run that target unless your ${buildfailed} property is set, regardless what value it holds so you need to use = <target name="buildresults" if="buildfailed"> instead. Regards, Gilbert --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by jpyork
> <condition property="buildfailed">
> <equals arg1="${buildresults}" arg2="failed"/> > </condition> Translation: if ( buildresults == "failed" ) { buildfailed = true; } // otherwise 'buildfailed' is not set > <target name="buildresults" unless="buildfailed"> > <fail message="Check deploy script for error" /> > </target> public target buildresults() { // unless clause if ( buildfailed != null ) { return; } fail("Check deploy script for error"); } Jan --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
In reply to this post by Jan.Materne
I got failure when
command="find . -maxdepth 1 -name ${reporting.db}.\*\.001 | wc -l"/> ... the trick is why doesn't 0 -eq 0 is when it has EOL so adding pipe xargs echo -n resolved this bug hope this helps test your condition. <target name="db2-test"> <sshexec host="${reporting.host}" trust="true" username="${reporting.user}" password="${reporting.password}" outputproperty="reporting.backup.count" failonerror="true" command="find . -maxdepth 1 -name ${reporting.db}.\*\.001 | wc -l | xargs echo -n"/> <condition property="missing.backup"> <equals arg1="${reporting.backup.count}" arg2="0"/> </condition> </target> <target name="testdb" depends="db2-test" unless="missing.backup"> ... </target> |
| Powered by Nabble | Edit this page |
