Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pragmatic Gradle for your Multi-Module Projects

Pragmatic Gradle for your Multi-Module Projects

DroidCon Boston 2018

https://github.com/cliveleehere/multimodulegradle

I will be updating this project as I find more tips!

Clive Lee

April 20, 2018
Tweet

More Decks by Clive Lee

Other Decks in Technology

Transcript

  1. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  2. But First… ! Update Gradle (4.6) ! Update Android Gradle

    Plugin (3.0.1) ! android-cache-fix-gradle-plugin
  3. But First… ! Update Gradle (4.6) ! Update Android Gradle

    Plugin (3.0.1) ! android-cache-fix-gradle-plugin ! Gradle Properties
  4. But First… ! Update Gradle (4.6) ! Update Android Gradle

    Plugin (3.0.1) ! android-cache-fix-gradle-plugin ! Gradle Properties AWESOME!
  5. Dependency Management, part 3 ./versions.gradle ext.deps = [:] def versions

    = [:] versions.dagger = "2.15" def deps = [:] def dagger = [:] dagger.runtime = "com.google.dagger:dagger$versions.dagger"
  6. Dependency Management, part 3 ./versions.gradle ext.deps = [:] def versions

    = [:] versions.dagger = "2.15" def deps = [:] def dagger = [:] dagger.runtime = "com.google.dagger:dagger$versions.dagger" deps.dagger = dagger ext.deps = deps
  7. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  8. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  9. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  10. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  11. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  12. feature1- domain feature2- domain ./f1-domain/ build.gradle apply from: “/shared- domain.gradle"

    ./f2-domain/ build.gradle apply from: “/shared- domain.gradle"
  13. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  14. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  15. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  16. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  17. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  18. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  19. App 1 feature1- presentation feature2- presentation App 2 ./shared-variants.gradle android

    {Ω flavorDimensions “function” productFlavors { ... } }œ configurations { ... }
  20. App 1 feature1- presentation feature2- presentation App 2 ./shared-variants.gradle android

    {Ω... flavorDimensions“function”productFlavors{ ... } }œ configurations { ... }
  21. App 1 feature1- presentation feature2- presentation App 2 ./shared-variants.gradle android

    {Ω... flavorDimensions“function”productFlavors{ ... } }œ configurations { ... } android.variantFilter { ... }
  22. App 1 feature1- presentation feature2- presentation App 2 ./shared-variants.gradle android

    {Ω... flavorDimensions“function”productFlavors{ ... } }œ configurations { ... } android.variantFilter { ... }
  23. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  24. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  25. App 1 App 2 ./shared-apps.gradle android { buildTypes { proguardFiles

    ... testProguardFile ... } } packagingOptions { ... }
  26. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  27. App 1 feature1- presentation feature1- data feature2- presentation feature2- data

    ui-common network App 2 ./shared-test.gradle android { sourceSets { test.java.srcDirs += [“...”] } }
  28. App 1 feature1- presentation feature1- data feature1- domain feature2- presentation

    feature2- data feature2- domain ui-common network App 2
  29. feature1- presentation feature1- data feature1- domain ./shared-feature1-tasks.gradle task cleanReports( type:

    Delete, group: 'Reports') { description "Delete Repots" delete ‘reportsDirectory' }
  30. “core” module ! For dependency management? ! Don’t enlarge the

    surface! ! Slower builds ! Shared gradle file instead
  31. Nested Modules ! Slower reloading project ! Does not show

    up in Android view ! Relative paths