// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4'
        classpath "io.realm:realm-gradle-plugin:1.2.0"
        classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

//tasks.withType(JavaCompile) {
//    options.encoding = 'UTF-8'
//}

//def hi = { msg ->
//    println(buildTime() + "--> " + msg)
//}

def hi(msg){
    println(buildTime() + "--> " + msg)
}

def getTime() {
//    return new Date().format("yyyy-MM-dd")
    return new Date().format("HHmmss")
}

def buildTime() {
    return new Date().format("yyyy-MM-dd HH:mm:ss.sss")
}

def hostName() {
    return System.getProperty("user.home").replaceAll("\\\\", "\\\\\\\\") + " @ " + System.getProperty("user.name") + " @ " + InetAddress.localHost.hostName
}

def osName() {
    return System.getProperty("os.name") + " @ " + System.getProperty("os.version") + " @ " + System.getProperty("sun.cpu.isalist")
}

def javaVersion() {
    return System.getProperty("java.home").replaceAll("\\\\", "\\\\\\\\") + " @ " + System.getProperty("java.version")
}

def winGitVersion() {
    def code = new ByteArrayOutputStream()
    exec {
        // 需要配置git.exe 的系统环境变量
        commandLine 'D:\\Git\\bin\\git.exe', '--version'
//        commandLine 'cmd'
        standardOutput = code
    }
    return code.toString()
}

def macGitVersion() {
    def code = new ByteArrayOutputStream()
    exec {
        // 需要配置git.exe 的系统环境变量
        commandLine 'git', '--version'
//        commandLine 'cmd'
        standardOutput = code
    }
    return code.toString()
}

def isMacOs() {
    if (osName().toString().contains("Mac")) {
        return true
    }
    return false
}
