|
5 | 5 | # Grease |
6 | 6 |
|
7 | 7 | A Gradle plugin for creating fat AARs, useful for distributing multiple modules in a single file. |
8 | | -To install the plugin, you must configure the build script classpath: |
| 8 | +To install the plugin, apply it to your Android project: |
9 | 9 |
|
10 | 10 | ```kotlin |
11 | | -buildscript { |
| 11 | +// settings.gradle.kts |
| 12 | +pluginManagement { |
12 | 13 | repositories { |
13 | | - jcenter() |
14 | | - google() |
15 | | - } |
16 | | - dependencies { |
17 | | - classpath("io.deepmedia.tools:grease:0.2.0") |
| 14 | + mavenCentral() |
18 | 15 | } |
19 | 16 | } |
20 | | -``` |
21 | 17 |
|
22 | | -## Usage |
| 18 | +// build.gradle.kts |
| 19 | +plugins { |
| 20 | + id("com.android.library") |
| 21 | + id("io.deepmedia.tools.grease") version "0.4.0" |
| 22 | +} |
| 23 | +``` |
23 | 24 |
|
24 | | -To apply the plugin, declare it in your build script with the `io.deepmedia.tools.grease` id. |
25 | | -This must be done after the com.android.library plugin: |
| 25 | +Note: it is important that Grease is applied *after* the Android library plugin. |
26 | 26 |
|
27 | | -```groovy |
28 | | -apply plugin: 'com.android.library' |
29 | | -apply plugin: 'io.deepmedia.tools.grease' |
30 | | -``` |
| 27 | +## Usage |
31 | 28 |
|
32 | 29 | Once applied, Grease will create Gradle configurations that you can use to select which of your |
33 | 30 | dependencies should be bundled in the final fat AAR. |
@@ -61,19 +58,21 @@ dependencies that you own, to be sure that they won't be present in the classpat |
61 | 58 |
|
62 | 59 | ### Transitivity |
63 | 60 |
|
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: |
| 61 | +By default, declaring a specific grease dependency **will not** include transitive dependencies. |
| 62 | +To do so, you can use grease configurations ending in `Tree`: |
66 | 63 |
|
67 | 64 | ```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 | | - } |
| 65 | +dependencies { |
| 66 | + grease("my-package:artifact:1.0.0") // not transitive |
| 67 | + greaseTree("my-other-package:other-artifact:1.0.0") // transitive |
78 | 68 | } |
79 | | -``` |
| 69 | +``` |
| 70 | + |
| 71 | +### Relocations |
| 72 | + |
| 73 | +We support relocations through the popular [Shadow](https://github.com/GradleUp/shadow) plugin. Inside the `grease` |
| 74 | +extension, you can use: |
| 75 | + |
| 76 | +- `relocate(prefix: String)` to relocate all included packages by prefixing them with the given prefix. Defaults to `"grease"`. |
| 77 | +- `relocate(from: String, to: String, configure: Action<SimpleRelocator>)` to register a package-specific relocator, |
| 78 | + as described in the [shadow plugin docs](https://gradleup.com/shadow/configuration/relocation/#relocating-packages) |
0 commit comments