plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'maven-publish'
}

ext {
    PUBLISH_ARTIFACT_ID = "jetmagic"
    PUBLISH_VERSION = "1.5.0"
}

apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"

android {
    namespace 'io.github.johannrosenberg.jetmagic'
    compileSdk 34

    defaultConfig {
        minSdk 25
        versionName "1.5.0"

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

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.5.1'
    }

    publishing {
        singleVariant('release') {
            withSourcesJar()
        }
    }
}

dependencies {
    def lifecycle_version = "2.7.0"

    implementation 'androidx.core:core-ktx:1.12.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.11.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
    implementation 'androidx.activity:activity-compose:1.8.2'
    implementation platform('androidx.compose:compose-bom:2023.08.00')
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    implementation "androidx.compose.material:material-icons-extended:1.5.4"
    implementation "androidx.compose.material:material:1.5.4"
    implementation "androidx.compose.runtime:runtime-livedata:1.5.4"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0'

    // Coil
    implementation "io.coil-kt:coil-compose:2.5.0"
    implementation "com.google.accompanist:accompanist-coil:0.15.0"

}

// This task is located in the Gradle window under Jetmagic > Jetmagic > Tasks > other > generateRepo
tasks.register('generateRepo', Zip) {
    //def publishTask = tasks.named('publishReleasePublicationToSonatypeRepository')
    def publishTask = tasks.named('publishReleasePublicationToMavenLocal')
    from publishTask.map { it.getRepository().getUrl() }
    into 'jetmagic-publish'
    archiveFileName.set('jetmagic.zip')
}



