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

buildscript {
    def isJitpackEnv = Boolean.parseBoolean(System.getenv("JITPACK"))
    println "isJitpackEnv = $isJitpackEnv"

    ext.kotlin_version = '1.6.10'
    ext.x2j_version = isJitpackEnv ? '1.1' : '-SNAPSHOT'
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        google()
        mavenLocal()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
//        classpath "com.github.7hens:android-x2j:$x2j_version"
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.6.10'
    id "android-x2j" apply false
}

allprojects {
    group = rootProject.properties["GROUP_ID"].toString()
    version = rootProject.properties["VERSION"].toString()
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        google()
        mavenLocal()
        maven { url "https://jitpack.io" }
    }
    tasks.withType(Javadoc) {
        excludes = ['**/*.kt']
        options.addStringOption('Xdoclint:none', '-quiet')
        options.addStringOption('encoding', 'UTF-8')
        options.addBooleanOption('Xdoclint:none', true)
    }
}

tasks.register('publishToMavenLocal') {
    dependsOn gradle.includedBuild("android-x2j").task(":publishToMavenLocal")
}
