0

I have a android project including some modules and want to build each module as a jar file including all depending sources and jar libraries.

Ive changed my gradle file and it builds my module nicely, but without the depending sources and jars.

Here is my gradle file

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main  {
            java {
                srcDir 'src'
            }
        }
    }
}

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


task clearJar(type: Delete) {
    delete 'build/libs/myFancyLib.jar'
}

task makeJar(type: Copy) {
    from('build/intermediates/bundles/release/')
    into('build/libs/')
    include('classes.jar')
    rename ('classes.jar', 'myFancyLib.jar')
}

makeJar.dependsOn(clearJar, build)
dknaack
  • 60,192
  • 27
  • 155
  • 202
  • You might find good clues in other questions on stackoverflow. How to build a source jar: http://stackoverflow.com/questions/11474729/how-to-build-sources-jar-with-gradle – Jolta Jun 15 '15 at 12:25
  • How to include all dependencies (including transitive ones) in a jar (AKA a Fat Jar) http://stackoverflow.com/questions/10986244/building-a-uberjar-with-gradle – Jolta Jun 15 '15 at 12:28

0 Answers0