buildscript {
    ext.kotlin_version = '1.6.10'
    ext.navigation_version = '2.1.0'

    repositories {
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.4'//不可随意更改，3.5.4支持<queries>标签
        classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
        //classpath 'com.jaredsburrows:gradle-license-plugin:0.9.0'
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://jitpack.io' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        flatDir {
            dirs project(':libs').file('aars')
        }
    }
}

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

static boolean isWindows() {
    String os = System.getProperty("os.name")
    def isWindows = os.toLowerCase().startsWith("win")
    System.println("isWindows? " + isWindows)
    return isWindows
}

static boolean isInJenkins() {
    def isJenkins = false
    Map<String, String> map = System.getenv()
    if (map == null) {
        return isJenkins
    }
    String str = map.get("Path")
    if (str != null) {
        return isJenkins;
    } else {
        str = ""
        Iterator it = map.iterator();
        while (it.hasNext()) {
            str += it.next();
        }
        isJenkins = str.contains("jenkins")
        System.println("isInJenkins? " + isJenkins)
        return isJenkins
    }
}

def isDebug() {
    def taskNames = gradle.startParameter.taskNames
    for (tn in taskNames) {
        if( (tn.contains("install") || tn.contains("assemble")) && tn.contains("Debug")) {
            return true
        }
    }
    return false
}

ext {
    compile_sdk_version = 29
    build_tools_version = '29.0.0'
    min_sdk_version = 22
    target_sdk_version = 23 //26(8.0)
    supportLibraryVersion = '28.0.0'
    arch_lifecycle_version = '2.1.0'
    arch_butterknife_version = '10.0.0'
    arch_material_version = '1.1.0'
    arch_arouter_version = '1.2.2'
    gson_version = '2.7'
    appcompat_version = '1.2.0'
    core_ktx_version = '1.3.2'
    okhttp_version = '4.9.0'
    room_version = '2.3.0'
    qmui_version = '1.4.0'
    mmkv_version = '1.2.14'
}

/**
 * 配置阶段开始前的监听回调
 */
this.beforeEvaluate {
    println 'root配置阶段开始前.........'
}
/**
 * 配置阶段完成以后的回调
 */
this.afterEvaluate {
    println 'root配置阶段完成.........'
}
/**
 * gradle执行完毕后的回调监听
 */
this.gradle.buildFinished {
    println 'root gradle执行完毕.........'
}

this.gradle.beforeProject {
    println 'root gradle执行之前.........'
}

this.gradle.afterProject {
    println 'root gradle执行之后.........'
}


