kaedea / intransitives

Gradle plugin for intransitive-complie dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Intransitives

Download version

Banner

Gradle plugin intransitives helps to make apis of transitive children dependencies invisible from user.

Problems

When you add an dependency in build.gradle, Gradle will also compile transitive children dependencies by default. This behavior makes the dependencies manager much simpler but something we hope to hide the apis of children dependencies. For example, picasso depends on okhttp as the following

APP -> Picasso -> OkHttp

If we compile picasso, we will also compile okhttp (that is how picasso works). In another word, the apis of okhttp is visible to us though we do not compile it explictly. If we do not announce compling okhttp explictly, we should not access its apis. Because the implementaion of picasso might changes so that it does not compile okhttp any more.

Solution

If we want to avoid accessing of transitive apis, we should set transitive = false of complie while transitive = true of runtime (hide the apis in compile time and package the apis in runtime). Such as

dependencies {
    implementation ('com.squareup.picasso:picasso:latest.release') {
        transitive = false
    }
    runtimeOnly ('com.squareup.picasso:picasso:latest.release') {
        transitive = true
    }
}

And this is how intransitives works.

Getting Started

Just apply the plugin in the build.gradle file of your module.

// ~/project/build.gradle

// 1. Add dependency
buildscript {
    repositories {
        jcenter()
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath 'com.kaedea:intransitives:latest.release'
    }
}

// 2. Apply plugin
apply plugin: 'com.kaedea.intransitives'
intransitives {
    // 3. Move your dependencies here in need
    implementation 'com.squareup.picasso:picasso:latest.release'
}

Use task :app:intransitives to dump your intransitive dependencies confinguration.

Contributing

Check CONTRIBUTING.md.

License

The project is Apache License, Version 2.0 licensed.

About

Gradle plugin for intransitive-complie dependencies.

License:Apache License 2.0


Languages

Language:Groovy 71.8%Language:Kotlin 28.2%