Skip to content

ab180/fatjar

Repository files navigation

FatJar

Getting started

Step 1 : Apply plugin

Add snippet below to your root build script file.

buildscript {
    repositories {
        maven {
            url "https://jitpack.io"
        }
    }
    dependencies {
        classpath "com.github.ab180:fatjar:{$tag}"
    }
}

Add snippet below to the build.gradle of your android library:

apply plugin: "co.ab180.fatjar"

Step 2 : Internalize dependencies

Change implementation or api to internalize while you want to embed the dependency in the library.

dependencies {
    // Local dependency
    internalize files("fantastic_library.jar")
    
    // Remote dependency
    internalize "com.google.code.gson:gson:1.+"
    
    // When 'transitive=true' is needed
    internalizeAll "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.+"
}

FatJar currently support .jar extension under the com.android.library plugin only

Optional : Change package name (Shadow)

Add repackage scope into build.gradle file.

repackage {
    def prefix = "com.mycompany"
    relocate "com.google.gson.**", "${prefix}.com.google.gson.@1"
    relocate "kotlin.**", "${prefix}.kotlin.@1"
}

Thanks