group 'de.mintware.barcode_scan'
version '1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.8.0'
    ext.protobuf_version = '0.9.1'
    ext.protocVersion = '3.11.0'
    ext.javaliteVersion = '3.11.0'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.protobuf:protobuf-gradle-plugin:$protobuf_version"
    }
}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.protobuf'

android {
    if (project.android.hasProperty("namespace")) {
        namespace("de.mintware.barcode_scan")
    }

    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        main.proto.srcDirs += '../protos'
    }
    defaultConfig {
        minSdkVersion 18
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'proguard-rules.pro'
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}


protobuf {
    // Configure the protoc executable
    protoc {
        if (osdetector.os == "osx") {
            artifact = "com.google.protobuf:protoc:$protocVersion:osx-x86_64"
        } else {
            artifact = "com.google.protobuf:protoc:$protocVersion"
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java { option 'lite' }
            }
        }
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'me.dm7.barcodescanner:zxing:1.9.8'
    implementation "com.google.protobuf:protobuf-javalite:$javaliteVersion"
    api 'com.google.android.material:material:1.1.0'
}
