Skip to content

Commit 0c93a04

Browse files
committed
Add transitivity notes
1 parent 281b336 commit 0c93a04

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ dependencies {
4747
// Can be used to enable grease only on specific library variants.
4848
greaseRelease("androidx.core:core:1.3.1")
4949
greaseDebug("androidx.core:core:1.3.1")
50+
greaseBlueCircleDebug("androidx.core:core:1.3.1")
51+
greaseGreenTriangleRelease("androidx.core:core:1.3.1")
5052
}
5153
```
5254

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

5759
If you don't control the projects that will consume the Grease AAR, you should only bundle in
5860
dependencies that you own, to be sure that they won't be present in the classpath of the consumer.
61+
62+
### Transitivity
63+
64+
When you add a grease dependency, by default all transitive dependencies are greased as well, so
65+
they will become part of the fat AARs. To avoid this, you can mark the configuration as non transitive:
66+
67+
```kotlin
68+
configurations["grease"].isTransitive = false
69+
configurations["greaseRelease"].isTransitive = false
70+
configurations["greaseDebug"].isTransitive = false
71+
72+
// Variant specific configurations are created lazily so you must wait for them to be
73+
// available before modifying them.
74+
configurations.configureEach {
75+
if (name == "greaseBlueCircleDebug") {
76+
isTransitive = false
77+
}
78+
}
79+
```

grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ open class GreasePlugin : Plugin<Project> {
380380
doFirst {
381381
log.i { "Executing for variant ${variant.name} and ${inputs.files.files.size} roots..." }
382382
inputs.files.files.forEach { inputJar ->
383-
log.i { "Found JAR root: $inputJar" }
383+
log.i { "Processing inputJar=$inputJar outputDir=${compileTask.get().destinationDirectory.get()}..." }
384384
val inputFiles = target.zipTree(inputJar).matching { include("**/*.class") }
385385
target.copy {
386386
from(inputFiles)

grease/src/main/kotlin/io/deepmedia/tools/grease/debug.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ internal fun debugConfigurationHierarchy(target: Project, logger: Logger) {
1616
val log = logger.child(this.name)
1717
val attrKeys = attributes.keySet()
1818
val attrs = attrKeys.map { it to attributes.getAttribute(it) }
19-
log.i { "Configuration added - canBeResolved:${isCanBeResolved} canBeConsumed:${isCanBeConsumed}" }
20-
log.i { "Configuration added - extendsFrom:[${extendsFrom.joinToString { it.name }}]" }
21-
log.i { "Configuration added - attributes:[${attrs.joinToString { "${it.first}:${it.second}" }}]" }
19+
log.i {
20+
"Configuration added - " +
21+
"canBeResolved=${isCanBeResolved} " +
22+
"canBeConsumed=${isCanBeConsumed} " +
23+
"extendsFrom=[${extendsFrom.joinToString { it.name }}] " +
24+
"attributes=[${attrs.joinToString { "${it.first}:${it.second}" }}]"
25+
}
2226
}
2327
}
2428
}

sample/build.gradle.kts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@ android {
4444
}
4545
}
4646

47+
configurations.configureEach {
48+
if (name == "greaseGreenCircleDebug") isTransitive = false
49+
}
50+
4751
dependencies {
4852
// Includes resource and some manifest changes
49-
grease("androidx.core:core:1.3.1")
53+
greaseDebug("androidx.core:core:1.3.2")
5054
// Includes native libraries
51-
grease("org.tensorflow:tensorflow-lite:2.3.0")
55+
greaseRelease("org.tensorflow:tensorflow-lite:2.3.0")
5256
// Manifest changes, layout resources
53-
grease("com.otaliastudios:cameraview:2.6.3")
57+
afterEvaluate {
58+
add("greaseGreenCircleDebug","com.otaliastudios:cameraview:2.6.3")
59+
}
5460
}

0 commit comments

Comments
 (0)