apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

android {
    namespace = 'com.termux.shared'
    compileSdkVersion project.properties.compileSdkVersion.toInteger()

    defaultConfig {
        minSdkVersion project.properties.minSdkVersion.toInteger()
        targetSdkVersion project.properties.targetSdkVersion.toInteger()
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            ndkBuild {
                cppFlags ''
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            jniDebuggable false
        }
        debug {
            minifyEnabled false
            jniDebuggable false
        }
    }

    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled = true

        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    externalNativeBuild {
        ndkBuild {
            path file('src/main/cpp/Android.mk')
        }
    }
    ndkVersion = System.getenv("JITPACK_NDK_VERSION") ?: project.properties.ndkVersion
    buildFeatures {
        viewBinding = false
    }
}

dependencies {
    testImplementation "junit:junit:4.13.2"
    androidTestImplementation "androidx.test.ext:junit:1.3.0"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.7.0"
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'

    implementation "androidx.appcompat:appcompat:1.7.1"
    implementation "androidx.annotation:annotation:1.9.1"

    implementation "androidx.drawerlayout:drawerlayout:1.2.0"

    implementation "androidx.core:core:1.17.0"
    implementation "com.google.android.material:material:1.13.0"
    implementation "com.google.guava:guava:33.5.0-jre"
    implementation "io.noties.markwon:core:$markwonVersion"
    implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
    implementation "io.noties.markwon:linkify:$markwonVersion"
    implementation "io.noties.markwon:recycler:$markwonVersion"
    //noinspection Aligned16KB
    implementation "com.github.ChickenHook:RestrictionBypass:2.2"

    implementation "androidx.window:window:1.5.0"

    implementation "androidx.viewpager:viewpager:1.1.0"
    implementation "androidx.viewpager2:viewpager2:1.1.0"
    implementation 'androidx.annotation:annotation-experimental:1.5.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
    implementation 'androidx.fragment:fragment-ktx:1.8.9'
    implementation 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.9.4'
    implementation 'androidx.loader:loader:1.1.0'
    implementation 'androidx.recyclerview:recyclerview:1.4.0'
    implementation 'androidx.savedstate:savedstate:1.3.3'
    implementation 'androidx.transition:transition:1.6.0'
    implementation 'androidx.versionedparcelable:versionedparcelable:1.2.1'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.3.0'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.2.0'

    // Bumping commons-io to a version higher than 2.5
    // will cause runtime exceptions on android < 8 due
    // to missing classes like java.nio.file.Path.
    implementation "commons-io:commons-io:2.20.0"

    implementation project(":terminal-view")

    implementation project(":termux-am-library")
}

tasks.register('sourceJar', Jar) {
    from android.sourceSets.main.java.srcDirs
    archiveClassifier = "sources"
}

tasks.withType(JavaCompile).configureEach {
    options.compilerArgs << "-Xlint:deprecation"
}

afterEvaluate {
    publishing {
        publications {
            // Creates a Maven publication called "release".
            release(MavenPublication) {
                from components.findByName('release')
                groupId = 'com.termux'
                artifactId = 'termux-shared'
                version = '0.118.0'
                artifact(sourceJar)
            }
        }
    }
}
