Skip to content

Commit

Permalink
Add transitivity notes
Browse files Browse the repository at this point in the history
  • Loading branch information
natario1 committed Jan 11, 2021
1 parent 281b336 commit 0c93a04
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ dependencies {
// Can be used to enable grease only on specific library variants.
greaseRelease("androidx.core:core:1.3.1")
greaseDebug("androidx.core:core:1.3.1")
greaseBlueCircleDebug("androidx.core:core:1.3.1")
greaseGreenTriangleRelease("androidx.core:core:1.3.1")
}
```

Expand All @@ -56,3 +58,22 @@ likely cause compile issue on projects that consume the Grease AAR, if they alre

If you don't control the projects that will consume the Grease AAR, you should only bundle in
dependencies that you own, to be sure that they won't be present in the classpath of the consumer.

### Transitivity

When you add a grease dependency, by default all transitive dependencies are greased as well, so
they will become part of the fat AARs. To avoid this, you can mark the configuration as non transitive:

```kotlin
configurations["grease"].isTransitive = false
configurations["greaseRelease"].isTransitive = false
configurations["greaseDebug"].isTransitive = false

// Variant specific configurations are created lazily so you must wait for them to be
// available before modifying them.
configurations.configureEach {
if (name == "greaseBlueCircleDebug") {
isTransitive = false
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ open class GreasePlugin : Plugin<Project> {
doFirst {
log.i { "Executing for variant ${variant.name} and ${inputs.files.files.size} roots..." }
inputs.files.files.forEach { inputJar ->
log.i { "Found JAR root: $inputJar" }
log.i { "Processing inputJar=$inputJar outputDir=${compileTask.get().destinationDirectory.get()}..." }
val inputFiles = target.zipTree(inputJar).matching { include("**/*.class") }
target.copy {
from(inputFiles)
Expand Down
10 changes: 7 additions & 3 deletions grease/src/main/kotlin/io/deepmedia/tools/grease/debug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ internal fun debugConfigurationHierarchy(target: Project, logger: Logger) {
val log = logger.child(this.name)
val attrKeys = attributes.keySet()
val attrs = attrKeys.map { it to attributes.getAttribute(it) }
log.i { "Configuration added - canBeResolved:${isCanBeResolved} canBeConsumed:${isCanBeConsumed}" }
log.i { "Configuration added - extendsFrom:[${extendsFrom.joinToString { it.name }}]" }
log.i { "Configuration added - attributes:[${attrs.joinToString { "${it.first}:${it.second}" }}]" }
log.i {
"Configuration added - " +
"canBeResolved=${isCanBeResolved} " +
"canBeConsumed=${isCanBeConsumed} " +
"extendsFrom=[${extendsFrom.joinToString { it.name }}] " +
"attributes=[${attrs.joinToString { "${it.first}:${it.second}" }}]"
}
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ android {
}
}

configurations.configureEach {
if (name == "greaseGreenCircleDebug") isTransitive = false
}

dependencies {
// Includes resource and some manifest changes
grease("androidx.core:core:1.3.1")
greaseDebug("androidx.core:core:1.3.2")
// Includes native libraries
grease("org.tensorflow:tensorflow-lite:2.3.0")
greaseRelease("org.tensorflow:tensorflow-lite:2.3.0")
// Manifest changes, layout resources
grease("com.otaliastudios:cameraview:2.6.3")
afterEvaluate {
add("greaseGreenCircleDebug","com.otaliastudios:cameraview:2.6.3")
}
}

0 comments on commit 0c93a04

Please sign in to comment.