Check if property has been set in phing
Asked Answered
D

2

8

How to check if property ${foo} has been set?

Bonus question: how to escape $ sign in <echo> so I could output ${foo} string (not the foo variable substitution)?

PS: tried to google and read documentation, but couldn't find the answers. It's likely I'm missing something

Delmardelmer answered 17/8, 2012 at 5:21 Comment(0)
H
16

You need to place an isset element inside the if element.

<if>
    <isset property="foo" />

The manual is available here.

Howell answered 20/8, 2012 at 9:0 Comment(2)
or add if="variable" as attribute of the tag to run it only if the variable is set. From experience, better to avoid complex conditional statements for maintenance reasonsEwald
The problem with both answers here is that they don't let you check if anything has been assigned to the respective properties.Dreamworld
S
0

If you just need to fail the build if a property is defined or not, check out the fail task:

http://www.phing.info/docs/guide/stable/FailTask.html

Sweettalk answered 21/9, 2014 at 16:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.