diff --git a/README.md b/README.md index c482d43..2c1486f 100644 --- a/README.md +++ b/README.md @@ -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") } ``` @@ -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 + } +} +``` \ No newline at end of file diff --git a/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt b/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt index 1ad51e6..0bda43a 100644 --- a/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt +++ b/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt @@ -380,7 +380,7 @@ open class GreasePlugin : Plugin { 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) diff --git a/grease/src/main/kotlin/io/deepmedia/tools/grease/debug.kt b/grease/src/main/kotlin/io/deepmedia/tools/grease/debug.kt index d3bac1e..f2f0d61 100644 --- a/grease/src/main/kotlin/io/deepmedia/tools/grease/debug.kt +++ b/grease/src/main/kotlin/io/deepmedia/tools/grease/debug.kt @@ -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}" }}]" + } } } } diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index bab1746..46124b8 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -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") + } } \ No newline at end of file