I found this answer about how to do it with groovy:
if (System.properties['os.name'].toLowerCase().contains('windows')) {
println "it's Windows"
} else {
println "it's not Windows"
}
Is there a better way?
解决方案
Actually, I looked at the gradle project and this looks a little cleaner as it uses ant's existing structure
import org.apache.tools.ant.taskdefs.condition.Os
task checkWin() << {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
println "*** WINDOWS "
}
}
I found this in the following gradle branch and it seems to work nicely gradle/gradle-core/branches/RB-0.3/build.gradle