kstanoev
7/24/2015 - 7:49 AM

Gradle file for exporting jar from Android Studio

Gradle file for exporting jar from Android Studio

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc2"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 22
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
}

// task to delete the old jar
task deleteOldJar(type: Delete) {
    delete 'release/ToastPlugin.jar'
}

// task to export contents as jar
task exportJar(type: Copy) {
    from('build/intermediates/bundles/release/')
    into('release')
    include('classes.jar')
    // name the plugin
    rename('classes.jar','ToastPlugin.jar')
}

exportJar.dependsOn(deleteOldJar, build)