plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'maven-publish'
    id 'kotlinx-serialization'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "$gmaps_parser_version"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            buildConfigField "String", "LIBRARY_VERSION", "\"$gmaps_parser_version\""
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

        debug {
            buildConfigField "String", "LIBRARY_VERSION", "\"$gmaps_parser_version\""
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        coreLibraryDesugaringEnabled true
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

ext {
    ktor_version = "1.5.1"
}

dependencies {
    implementation project(":navparser")
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlix_coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlix_serialization_version"
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$kotlix_serialization_version"
    implementation "io.ktor:ktor-server-core:$ktor_version"
    implementation "io.ktor:ktor-server-netty:$ktor_version"
    implementation "io.ktor:ktor-websockets:$ktor_version"
//    implementation "ch.qos.logback:logback-classic:1.2.3"// for ktor logging
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release

                groupId = "$gmaps_parser_groupId"
                artifactId = 'navparser-websocket'
                version = "$gmaps_parser_version"
            }

            debug(MavenPublication) {
                from components.debug

                groupId = "$gmaps_parser_groupId"
                artifactId = 'navparser-websocket.debug'
                version = "$gmaps_parser_version"
                alias true
            }
        }
    }
}
