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

buildscript {
    ext {
        kotlin_version = '1.7.21'
    }

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'

        classpath 'com.google.firebase:perf-plugin:1.4.2'

        // Add the Firebase Crashlytics Gradle plugin.
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        maven { url 'https://jitpack.io' }
        mavenCentral()
    }


//    gradle.projectsEvaluated {
//        tasks.withType(JavaCompile) {
//            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
//        }
//    }
}

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

task buildBase() {
    doFirst {
        copy {
            from 'dynamic__base/src/main/java/it/integry'
            into 'app/src/main/java/it/integry'
        }
    }

    dependsOn "app:build"

    doLast {
        copy {
            from 'app/build/outputs/apk/release'
            into 'dist/release/_base'
        }
    }
}

task buildFrudis() {
    doFirst {
        copy {
            from 'dynamic_frudis/src/main/java/it/integry'
            into 'app/src/main/java/it/integry'
        }
    }

    dependsOn "app:build"

    doLast {
        copy {
            from 'app/build/outputs/apk/release'
            into 'dist/release/frudis'
        }
    }
}

task buildGramm() {
    doFirst {
        copy {
            from 'dynamic_gramm/src/main/java/it/integry'
            into 'app/src/main/java/it/integry'
        }
    }

    dependsOn "app:build"

    doLast {
        copy {
            from 'app/build/outputs/apk/release'
            into 'dist/release/gramm'
        }
    }
}

task buildIme() {
    doFirst {
        copy {
            from 'dynamic_ime/src/main/java/it/integry'
            into 'app/src/main/java/it/integry'
        }
    }

    dependsOn "app:build"

    doLast {
        copy {
            from 'app/build/outputs/apk/release'
            into 'dist/release/ime'
        }
    }
}

task buildSaporiVeriPV() {
    doFirst {
        copy {
            from 'dynamic_saporiveri_pv/src/main/java/it/integry'
            into 'app/src/main/java/it/integry'
        }
    }

    dependsOn "app:build"

    doLast {
        copy {
            from 'app/build/outputs/apk/release'
            into 'dist/release/saporiveri_pv'
        }
    }
}

task buildSaporiVeri() {
    doFirst {
        copy {
            from 'dynamic_saporiveri/src/main/java/it/integry'
            into 'app/src/main/java/it/integry'
        }
    }

    dependsOn "app:build"

    doLast {
        copy {
            from 'app/build/outputs/apk/release'
            into 'dist/release/saporiveri'
        }
    }
}

task buildVGAlimenti() {
    doFirst {
        copy {
            from 'dynamic_vgalimenti/src/main/java/it/integry'
            into 'app/src/main/java/it/integry'
        }
    }

    dependsOn "app:build"

    doLast {
        copy {
            from 'app/build/outputs/apk/release'
            into 'dist/release/vgalimenti'
        }
    }
}