How to detect the current OS from Gradle

前端 未结 6 1872
囚心锁ツ
囚心锁ツ 2020-12-08 17:57

I found this answer about how to do it with Groovy:

Detecting the platform (Window or Linux) by Groovy/Grails:



        
6条回答
  •  萌比男神i
    2020-12-08 18:28

    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

提交回复
热议问题