How to detect the current OS from Gradle

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

Leave a Comment

File not found.