peterk
peterk

Reputation: 5444

How to test for operating system in ant build

It seems the only reliably provided property by ant is the "os.name" property. However this name has variants ;lie "Windows 8" "Windows 7" etc

But for my purposes both are "Windows" -

Is there a way to conditionally set a property based on a partial string match of another property value like the pseudo code below? specifically the os.name as the source value? using the default task set provided with a generic ant install?

if(a.property 'contains' "Windows")
    another.property = "windows value"
else if(a.property contains 'Linux')
    another.property = "linux value"
endif

Upvotes: 0

Views: 641

Answers (1)

Oleg Pavliv
Oleg Pavliv

Reputation: 21192

You can use os family

        <condition property="another.property" value="windows value" >
            <os family="windows"  />
        </condition>


        <condition property="another.property"  value="linux value" >
            <os family="unix"  name="Linux"/>
        </condition>

Upvotes: 2

Related Questions