apply plugin: 'com.android.library'

android {
    compileSdkVersion compile_sdk_version

    defaultConfig {
        minSdkVersion min_sdk_version
        targetSdkVersion target_sdk_version
        versionCode 1
        versionName '0.8.9.4'
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }

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

    compileOptions {
        sourceCompatibility = java_version
        targetCompatibility = java_version
    }

    buildFeatures {
        buildConfig = false
    }

    lintOptions {
        abortOnError false
    }

    tasks.withType(Javadoc) {
        options.addStringOption('Xdoclint:none', '-quiet')
        options.addStringOption('encoding', 'UTF-8')
        options.addStringOption('charSet', 'UTF-8')
    }
}

dependencies {
    implementation "androidx.annotation:annotation:$androidx_annotation_version"
    implementation "androidx.recyclerview:recyclerview:$androidx_recyclerview_version"

    testImplementation "junit:junit:$junit_version"

    androidTestImplementation "androidx.appcompat:appcompat:$androidx_appcompat_version"
    androidTestImplementation "androidx.test:rules:$androidx_test_version"
    androidTestImplementation "androidx.test:runner:$androidx_test_version"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidx_test_espresso_version"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$androidx_test_espresso_version"
    androidTestImplementation "androidx.test.ext:junit:$androidx_test_ext_version"
    androidTestImplementation "junit:junit:$junit_version"
}

// Configure the publishing
apply plugin: 'maven-publish'

task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    android.libraryVariants.all { variant ->
        if (variant.name == 'release') {
            owner.classpath += variant.javaCompileProvider.get().classpath
        }
    }
    exclude '**/R.html', '**/R.*.html', '**/index.html'
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    archiveClassifier.set('javadoc')
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    archiveClassifier.set('sources')
    from android.sourceSets.main.java.srcDirs
}

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

                groupId = 'com.evrencoskun.library'
                artifactId = 'tableview'
                version = android.defaultConfig.versionName

                artifact androidJavadocsJar
                artifact androidSourcesJar

                pom {
                    name = 'TableView'
                    description = 'TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.'
                    url = 'https://github.com/evrencoskun/TableView'
                }
            }
        }

        repositories {
            maven {
                url = 'https://api.bintray.com/content/evrencoskun/artifact-sandbox/'
            }
        }
    }
}
