├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ysfcyln
│ │ └── daggermultimodule
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── ysfcyln
│ │ │ └── daggermultimodule
│ │ │ ├── MainActivity.kt
│ │ │ ├── MyApp.kt
│ │ │ └── di
│ │ │ ├── AppComponent.kt
│ │ │ ├── DiProvider.kt
│ │ │ ├── SubComponents.kt
│ │ │ ├── SubComponentsModule.kt
│ │ │ └── main
│ │ │ ├── MainComponent.kt
│ │ │ └── MainComponentProvider.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── ysfcyln
│ └── daggermultimodule
│ └── ExampleUnitTest.kt
├── base
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ysfcyln
│ │ └── base
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── ysfcyln
│ │ └── base
│ │ ├── ActivityScope.kt
│ │ ├── BaseModule.kt
│ │ ├── DatabaseService.kt
│ │ └── NetworkService.kt
│ └── test
│ └── java
│ └── com
│ └── ysfcyln
│ └── base
│ └── ExampleUnitTest.kt
├── build.gradle
├── feature-one
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ysfcyln
│ │ └── feature_one
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── ysfcyln
│ │ │ └── feature_one
│ │ │ ├── FeatureOneActivity.kt
│ │ │ ├── FeatureOneObject.kt
│ │ │ └── di
│ │ │ ├── FeatureOneComponent.kt
│ │ │ ├── FeatureOneComponentProvider.kt
│ │ │ └── FeatureOneModule.kt
│ └── res
│ │ ├── layout
│ │ └── activity_feature_one.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── ysfcyln
│ └── feature_one
│ └── ExampleUnitTest.kt
├── feature-three
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ysfcyln
│ │ └── feature_three
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── ysfcyln
│ │ │ └── feature_three
│ │ │ ├── FeatureThreeActivity.kt
│ │ │ ├── FeatureThreeObject.kt
│ │ │ └── di
│ │ │ ├── FeatureThreeComponent.kt
│ │ │ ├── FeatureThreeComponentProvider.kt
│ │ │ └── FeatureThreeModule.kt
│ └── res
│ │ ├── layout
│ │ └── activity_feature_three.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── ysfcyln
│ └── feature_three
│ └── ExampleUnitTest.kt
├── feature-two
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ysfcyln
│ │ └── feature_two
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── ysfcyln
│ │ │ └── feature_two
│ │ │ ├── FeatureTwoActivity.kt
│ │ │ ├── FeatureTwoObject.kt
│ │ │ └── di
│ │ │ ├── FeatureTwoComponent.kt
│ │ │ ├── FeatureTwoComponentProvider.kt
│ │ │ └── FeatureTwoModule.kt
│ └── res
│ │ ├── layout
│ │ └── activity_feature_two.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── ysfcyln
│ └── feature_two
│ └── ExampleUnitTest.kt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/android,androidstudio
3 | # Edit at https://www.gitignore.io/?templates=android,androidstudio
4 |
5 | ### Android ###
6 | # Built application files
7 | *.apk
8 | *.ap_
9 | *.aab
10 |
11 | # Files for the ART/Dalvik VM
12 | *.dex
13 |
14 | # Java class files
15 | *.class
16 |
17 | # Generated files
18 | bin/
19 | gen/
20 | out/
21 | release/
22 |
23 | # Gradle files
24 | .gradle/
25 | build/
26 |
27 | # Local configuration file (sdk path, etc)
28 | local.properties
29 |
30 | # Proguard folder generated by Eclipse
31 | proguard/
32 |
33 | # Log Files
34 | *.log
35 |
36 | # Android Studio Navigation editor temp files
37 | .navigation/
38 |
39 | # Android Studio captures folder
40 | captures/
41 |
42 | # IntelliJ
43 | *.iml
44 | .idea/workspace.xml
45 | .idea/tasks.xml
46 | .idea/gradle.xml
47 | .idea/assetWizardSettings.xml
48 | .idea/dictionaries
49 | .idea/libraries
50 | # Android Studio 3 in .gitignore file.
51 | .idea/caches
52 | .idea/modules.xml
53 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
54 | .idea/navEditor.xml
55 |
56 | # Keystore files
57 | # Uncomment the following lines if you do not want to check your keystore files in.
58 | #*.jks
59 | #*.keystore
60 |
61 | # External native build folder generated in Android Studio 2.2 and later
62 | .externalNativeBuild
63 |
64 | # Google Services (e.g. APIs or Firebase)
65 | # google-services.json
66 |
67 | # Freeline
68 | freeline.py
69 | freeline/
70 | freeline_project_description.json
71 |
72 | # fastlane
73 | fastlane/report.xml
74 | fastlane/Preview.html
75 | fastlane/screenshots
76 | fastlane/test_output
77 | fastlane/readme.md
78 |
79 | # Version control
80 | vcs.xml
81 |
82 | # lint
83 | lint/intermediates/
84 | lint/generated/
85 | lint/outputs/
86 | lint/tmp/
87 | # lint/reports/
88 |
89 | ### Android Patch ###
90 | gen-external-apklibs
91 | output.json
92 |
93 | # Replacement of .externalNativeBuild directories introduced
94 | # with Android Studio 3.5.
95 | .cxx/
96 |
97 | ### AndroidStudio ###
98 | # Covers files to be ignored for android development using Android Studio.
99 |
100 | # Built application files
101 |
102 | # Files for the ART/Dalvik VM
103 |
104 | # Java class files
105 |
106 | # Generated files
107 |
108 | # Gradle files
109 | .gradle
110 |
111 | # Signing files
112 | .signing/
113 |
114 | # Local configuration file (sdk path, etc)
115 |
116 | # Proguard folder generated by Eclipse
117 |
118 | # Log Files
119 |
120 | # Android Studio
121 | /*/build/
122 | /*/local.properties
123 | /*/out
124 | /*/*/build
125 | /*/*/production
126 | *.ipr
127 | *~
128 | *.swp
129 |
130 | # Android Patch
131 |
132 | # External native build folder generated in Android Studio 2.2 and later
133 |
134 | # NDK
135 | obj/
136 |
137 | # IntelliJ IDEA
138 | *.iws
139 | /out/
140 |
141 | # User-specific configurations
142 | .idea/caches/
143 | .idea/libraries/
144 | .idea/shelf/
145 | .idea/.name
146 | .idea/compiler.xml
147 | .idea/copyright/profiles_settings.xml
148 | .idea/encodings.xml
149 | .idea/misc.xml
150 | .idea/scopes/scope_settings.xml
151 | .idea/vcs.xml
152 | .idea/jsLibraryMappings.xml
153 | .idea/datasources.xml
154 | .idea/dataSources.ids
155 | .idea/sqlDataSources.xml
156 | .idea/dynamic.xml
157 | .idea/uiDesigner.xml
158 |
159 | # OS-specific files
160 | .DS_Store
161 | .DS_Store?
162 | ._*
163 | .Spotlight-V100
164 | .Trashes
165 | ehthumbs.db
166 | Thumbs.db
167 |
168 | # Legacy Eclipse project files
169 | .classpath
170 | .project
171 | .cproject
172 | .settings/
173 |
174 | # Mobile Tools for Java (J2ME)
175 | .mtj.tmp/
176 |
177 | # Package Files #
178 | *.war
179 | *.ear
180 |
181 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
182 | hs_err_pid*
183 |
184 | ## Plugin-specific files:
185 |
186 | # mpeltonen/sbt-idea plugin
187 | .idea_modules/
188 |
189 | # JIRA plugin
190 | atlassian-ide-plugin.xml
191 |
192 | # Mongo Explorer plugin
193 | .idea/mongoSettings.xml
194 |
195 | # Crashlytics plugin (for Android Studio and IntelliJ)
196 | com_crashlytics_export_strings.xml
197 | crashlytics.properties
198 | crashlytics-build.properties
199 | fabric.properties
200 |
201 | ### AndroidStudio Patch ###
202 |
203 | !/gradle/wrapper/gradle-wrapper.jar
204 |
205 | # End of https://www.gitignore.io/api/android,androidstudio
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Dagger Multi Module Android
2 | Plain Dagger implementation in multi module project
3 | ### Articles
4 |
5 | - [Offical android dagger documentation](https://developer.android.com/training/dependency-injection/dagger-multi-module)
6 | - [Mindorks Multi-Module-Dagger article](https://blog.mindorks.com/dagger-in-a-multi-module-project)
7 | - [Step by step multi module dagger implementation](https://proandroiddev.com/android-multi-module-dagger-a-real-use-case-step-by-step-bbc03500f2f9)
8 | ### Reference projects that I get inspired
9 | - [https://github.com/MindorksOpenSource/Dagger-Multi-Module-Android](https://github.com/MindorksOpenSource/Dagger-Multi-Module-Android)
10 | - [https://github.com/elye/demo_android_dagger_modules_setup](https://github.com/elye/demo_android_dagger_modules_setup)
11 | - [https://github.com/Ladgertha/Dagger-Multi-Modules](https://github.com/Ladgertha/Dagger-Multi-Modules)
12 |
13 | Feel free to contribute
14 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "29.0.2"
9 |
10 | defaultConfig {
11 | applicationId "com.ysfcyln.daggermultimodule"
12 | minSdkVersion 21
13 | targetSdkVersion 29
14 | versionCode 1
15 | versionName "1.0"
16 |
17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 |
32 | implementation project(":base")
33 | implementation project(":feature-one")
34 | implementation project(":feature-two")
35 | implementation project(":feature-three")
36 |
37 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
38 | implementation 'androidx.appcompat:appcompat:1.1.0'
39 | implementation 'androidx.core:core-ktx:1.2.0'
40 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
41 | testImplementation 'junit:junit:4.12'
42 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
44 |
45 | // Dagger dependencies
46 | implementation "com.google.dagger:dagger:$daggerVersion"
47 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
48 | }
49 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ysfcyln/daggermultimodule/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.ysfcyln.daggermultimodule", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule
2 |
3 | import android.content.Intent
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.util.Log
7 | import com.ysfcyln.base.DatabaseService
8 | import com.ysfcyln.base.NetworkService
9 | import com.ysfcyln.daggermultimodule.R
10 | import com.ysfcyln.daggermultimodule.di.main.MainComponentProvider
11 | import com.ysfcyln.feature_one.FeatureOneActivity
12 | import com.ysfcyln.feature_two.FeatureTwoActivity
13 | import kotlinx.android.synthetic.main.activity_main.*
14 | import javax.inject.Inject
15 |
16 | class MainActivity : AppCompatActivity() {
17 |
18 | @Inject
19 | lateinit var databaseService: DatabaseService
20 |
21 | @Inject
22 | lateinit var networkService: NetworkService
23 |
24 | /**
25 | * Create component and inject
26 | */
27 | private fun inject() {
28 | // When rotation happens component and its dependencies recreated :(
29 | val mainComponent = (application as MainComponentProvider).provideMainComponent()
30 | mainComponent.inject(this)
31 | }
32 |
33 | override fun onCreate(savedInstanceState: Bundle?) {
34 | inject()
35 | super.onCreate(savedInstanceState)
36 | setContentView(R.layout.activity_main)
37 | Log.d("MainActivity", databaseService.toString())
38 | Log.d("MainActivity", networkService.toString())
39 |
40 | clickListeners()
41 | }
42 |
43 | /**
44 | * View click listeners
45 | */
46 | private fun clickListeners() {
47 | btnFeatureOne.setOnClickListener {
48 | startActivity(Intent(this, FeatureOneActivity::class.java))
49 | }
50 |
51 | btnFeatureTwo.setOnClickListener {
52 | startActivity(Intent(this, FeatureTwoActivity::class.java))
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/MyApp.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule
2 |
3 | import android.app.Application
4 | import com.ysfcyln.daggermultimodule.di.DiProvider
5 | import com.ysfcyln.daggermultimodule.di.SubComponents
6 |
7 | class MyApp : Application(), SubComponents {
8 |
9 | override fun onCreate() {
10 | super.onCreate()
11 | DiProvider.buildDi(this)
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/di/AppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule.di
2 |
3 | import android.app.Application
4 | import com.ysfcyln.base.BaseModule
5 | import com.ysfcyln.daggermultimodule.di.main.MainComponent
6 | import com.ysfcyln.feature_one.di.FeatureOneComponent
7 | import com.ysfcyln.feature_three.di.FeatureThreeComponent
8 | import com.ysfcyln.feature_two.di.FeatureTwoComponent
9 | import dagger.BindsInstance
10 | import dagger.Component
11 | import javax.inject.Singleton
12 |
13 | @Singleton
14 | @Component(
15 | modules = [
16 | BaseModule::class,
17 | SubComponentsModule::class
18 | ]
19 | )
20 | interface AppComponent {
21 |
22 | /**
23 | * A {@see [Component.Factory]} that initializes necessary implementations
24 | */
25 | @Component.Factory
26 | interface Factory {
27 | fun create(@BindsInstance application: Application): AppComponent
28 | }
29 |
30 | // Save the reference of factories in the app component for creating sub components
31 | fun mainComponent() : MainComponent.Factory
32 |
33 | // Save the reference of factories in the app component for creating sub components
34 | fun featureOneComponent() : FeatureOneComponent.Factory
35 |
36 | // Save the reference of factories in the app component for creating sub components
37 | fun featureTwoComponent() : FeatureTwoComponent.Factory
38 |
39 | // Save the reference of factories in the app component for creating sub components
40 | fun featureThreeComponent() : FeatureThreeComponent.Factory
41 |
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/di/DiProvider.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule.di
2 |
3 | import android.app.Application
4 |
5 | object DiProvider {
6 | private lateinit var appComponent: AppComponent
7 |
8 | @JvmStatic
9 | fun appComponent() = appComponent
10 |
11 | fun buildDi(application: Application) {
12 | appComponent = DaggerAppComponent.factory().create(application)
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/di/SubComponents.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule.di
2 |
3 | import com.ysfcyln.daggermultimodule.di.main.MainComponent
4 | import com.ysfcyln.daggermultimodule.di.main.MainComponentProvider
5 | import com.ysfcyln.feature_one.di.FeatureOneComponent
6 | import com.ysfcyln.feature_one.di.FeatureOneComponentProvider
7 | import com.ysfcyln.feature_three.di.FeatureThreeComponent
8 | import com.ysfcyln.feature_three.di.FeatureThreeComponentProvider
9 | import com.ysfcyln.feature_two.di.FeatureTwoComponent
10 | import com.ysfcyln.feature_two.di.FeatureTwoComponentProvider
11 |
12 | interface SubComponents: MainComponentProvider, FeatureOneComponentProvider, FeatureTwoComponentProvider,
13 | FeatureThreeComponentProvider {
14 |
15 | override fun provideMainComponent(): MainComponent {
16 | return DiProvider.appComponent().mainComponent().create()
17 | }
18 |
19 | override fun provideFeatureOneComponent(): FeatureOneComponent {
20 | return DiProvider.appComponent().featureOneComponent().create()
21 | }
22 |
23 | override fun provideFeatureTwoComponent(): FeatureTwoComponent {
24 | return DiProvider.appComponent().featureTwoComponent().create()
25 | }
26 |
27 | override fun provideFeatureThreeComponent(): FeatureThreeComponent {
28 | return DiProvider.appComponent().featureThreeComponent().create()
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/di/SubComponentsModule.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule.di
2 |
3 | import com.ysfcyln.daggermultimodule.di.main.MainComponent
4 | import com.ysfcyln.feature_one.di.FeatureOneComponent
5 | import com.ysfcyln.feature_three.di.FeatureThreeComponent
6 | import com.ysfcyln.feature_two.di.FeatureTwoComponent
7 | import dagger.Module
8 |
9 | /**
10 | * Associate SubComponents with AppComponent
11 | */
12 | @Module(
13 | subcomponents = [
14 | MainComponent::class,
15 | FeatureOneComponent::class,
16 | FeatureTwoComponent::class,
17 | FeatureThreeComponent::class
18 | ]
19 | )
20 | class SubComponentsModule {
21 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/di/main/MainComponent.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule.di.main
2 |
3 | import com.ysfcyln.daggermultimodule.MainActivity
4 | import dagger.Subcomponent
5 |
6 | @Subcomponent(
7 | modules = [
8 | // Bounded main activity necessary modules comes here
9 | ]
10 | )
11 | interface MainComponent {
12 |
13 | @Subcomponent.Factory
14 | interface Factory {
15 | fun create() : MainComponent
16 | }
17 |
18 | fun inject(mainActivity: MainActivity) // Add main activity to Dagger graph
19 |
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ysfcyln/daggermultimodule/di/main/MainComponentProvider.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule.di.main
2 |
3 | interface MainComponentProvider {
4 | fun provideMainComponent(): MainComponent
5 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DaggerMultiModule
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/ysfcyln/daggermultimodule/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.daggermultimodule
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/base/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/base/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "29.0.2"
9 |
10 | defaultConfig {
11 | minSdkVersion 21
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles 'consumer-rules.pro'
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
32 | implementation 'androidx.appcompat:appcompat:1.1.0'
33 | implementation 'androidx.core:core-ktx:1.2.0'
34 | testImplementation 'junit:junit:4.12'
35 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
36 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
37 |
38 | // Dagger dependencies
39 | implementation "com.google.dagger:dagger:$daggerVersion"
40 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
41 | }
42 |
--------------------------------------------------------------------------------
/base/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/base/consumer-rules.pro
--------------------------------------------------------------------------------
/base/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/base/src/androidTest/java/com/ysfcyln/base/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.base
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.ysfcyln.base.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/base/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/base/src/main/java/com/ysfcyln/base/ActivityScope.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.base
2 |
3 | import javax.inject.Scope
4 |
5 | @Scope
6 | @Retention(AnnotationRetention.RUNTIME)
7 | annotation class ActivityScope {
8 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/ysfcyln/base/BaseModule.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.base
2 |
3 | import dagger.Module
4 | import dagger.Provides
5 | import javax.inject.Singleton
6 |
7 | @Module
8 | class BaseModule {
9 |
10 | @Provides
11 | @Singleton
12 | fun provideDatabaseService() = DatabaseService()
13 |
14 | @Provides
15 | @Singleton
16 | fun provideNetworkService() = NetworkService()
17 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/ysfcyln/base/DatabaseService.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.base
2 |
3 | import javax.inject.Singleton
4 |
5 | @Singleton
6 | class DatabaseService {
7 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/ysfcyln/base/NetworkService.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.base
2 |
3 | class NetworkService {
4 | }
--------------------------------------------------------------------------------
/base/src/test/java/com/ysfcyln/base/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.base
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.72'
5 | repositories {
6 | google()
7 | jcenter()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.6.3'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 |
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
31 | ext {
32 | daggerVersion = '2.27'
33 | }
34 |
--------------------------------------------------------------------------------
/feature-one/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/feature-one/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "29.0.2"
9 |
10 | defaultConfig {
11 | minSdkVersion 21
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles 'consumer-rules.pro'
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 |
32 | implementation project(":base")
33 |
34 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
35 | implementation 'androidx.appcompat:appcompat:1.1.0'
36 | implementation 'androidx.core:core-ktx:1.2.0'
37 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
38 | testImplementation 'junit:junit:4.12'
39 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
40 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
41 |
42 | // Dagger dependencies
43 | implementation "com.google.dagger:dagger:$daggerVersion"
44 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
45 | }
46 |
--------------------------------------------------------------------------------
/feature-one/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/feature-one/consumer-rules.pro
--------------------------------------------------------------------------------
/feature-one/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/feature-one/src/androidTest/java/com/ysfcyln/feature_one/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_one
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.ysfcyln.feature_one.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/feature-one/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/feature-one/src/main/java/com/ysfcyln/feature_one/FeatureOneActivity.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_one
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.util.Log
6 | import com.ysfcyln.base.DatabaseService
7 | import com.ysfcyln.base.NetworkService
8 | import com.ysfcyln.feature_one.di.FeatureOneComponentProvider
9 | import javax.inject.Inject
10 |
11 | class FeatureOneActivity : AppCompatActivity() {
12 |
13 | @Inject
14 | lateinit var databaseService: DatabaseService
15 |
16 | @Inject
17 | lateinit var networkService: NetworkService
18 |
19 | @Inject
20 | lateinit var featureOneObject: FeatureOneObject
21 |
22 | /**
23 | * Create component and inject
24 | */
25 | private fun inject() {
26 | // When rotation happens component and its dependencies recreated :(
27 | val featureOneComponent = (application as FeatureOneComponentProvider).provideFeatureOneComponent()
28 | featureOneComponent.inject(this)
29 | }
30 |
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | inject()
33 | super.onCreate(savedInstanceState)
34 | setContentView(R.layout.activity_feature_one)
35 | Log.d("FeatureOneActivity", databaseService.toString())
36 | Log.d("FeatureOneActivity", networkService.toString())
37 | Log.d("FeatureOneActivity", featureOneObject.toString())
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/feature-one/src/main/java/com/ysfcyln/feature_one/FeatureOneObject.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_one
2 |
3 | class FeatureOneObject {
4 | }
--------------------------------------------------------------------------------
/feature-one/src/main/java/com/ysfcyln/feature_one/di/FeatureOneComponent.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_one.di
2 |
3 | import com.ysfcyln.base.ActivityScope
4 | import com.ysfcyln.feature_one.FeatureOneActivity
5 | import dagger.Subcomponent
6 |
7 | @ActivityScope
8 | @Subcomponent(
9 | modules = [
10 | // Bounded feature one activity necessary modules comes here
11 | FeatureOneModule::class
12 | ]
13 | )
14 | interface FeatureOneComponent {
15 |
16 | @Subcomponent.Factory
17 | interface Factory {
18 | fun create() : FeatureOneComponent
19 | }
20 |
21 | fun inject(featureOneActivity: FeatureOneActivity) // Add feature one activity to Dagger graph
22 |
23 | }
--------------------------------------------------------------------------------
/feature-one/src/main/java/com/ysfcyln/feature_one/di/FeatureOneComponentProvider.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_one.di
2 |
3 | interface FeatureOneComponentProvider {
4 |
5 | fun provideFeatureOneComponent() : FeatureOneComponent
6 |
7 | }
--------------------------------------------------------------------------------
/feature-one/src/main/java/com/ysfcyln/feature_one/di/FeatureOneModule.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_one.di
2 |
3 | import com.ysfcyln.feature_one.FeatureOneObject
4 | import dagger.Module
5 | import dagger.Provides
6 |
7 | @Module
8 | class FeatureOneModule {
9 |
10 | @Provides
11 | fun provideFeatureOneObject() = FeatureOneObject()
12 |
13 | }
--------------------------------------------------------------------------------
/feature-one/src/main/res/layout/activity_feature_one.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/feature-one/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature-one/src/test/java/com/ysfcyln/feature_one/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_one
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/feature-three/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/feature-three/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "29.0.2"
9 |
10 | defaultConfig {
11 | minSdkVersion 21
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles 'consumer-rules.pro'
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 |
32 | implementation project(":base")
33 |
34 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
35 | implementation 'androidx.appcompat:appcompat:1.1.0'
36 | implementation 'androidx.core:core-ktx:1.2.0'
37 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
38 | testImplementation 'junit:junit:4.12'
39 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
40 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
41 |
42 | // Dagger dependencies
43 | implementation "com.google.dagger:dagger:$daggerVersion"
44 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
45 | }
46 |
--------------------------------------------------------------------------------
/feature-three/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/feature-three/consumer-rules.pro
--------------------------------------------------------------------------------
/feature-three/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/feature-three/src/androidTest/java/com/ysfcyln/feature_three/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_three
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.ysfcyln.feature_three.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/feature-three/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/feature-three/src/main/java/com/ysfcyln/feature_three/FeatureThreeActivity.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_three
2 |
3 | import androidx.appcompat.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.util.Log
6 | import com.ysfcyln.base.DatabaseService
7 | import com.ysfcyln.base.NetworkService
8 | import com.ysfcyln.feature_three.di.FeatureThreeComponentProvider
9 | import javax.inject.Inject
10 |
11 | class FeatureThreeActivity : AppCompatActivity() {
12 |
13 | @Inject
14 | lateinit var databaseService: DatabaseService
15 |
16 | @Inject
17 | lateinit var networkService: NetworkService
18 |
19 | @Inject
20 | lateinit var featureThreeObject: FeatureThreeObject
21 |
22 | /**
23 | * Create component and inject
24 | */
25 | private fun inject() {
26 | // When rotation happens component and its dependencies recreated :(
27 | val featureThreeComponent = (application as FeatureThreeComponentProvider).provideFeatureThreeComponent()
28 | featureThreeComponent.inject(this)
29 | }
30 |
31 | override fun onCreate(savedInstanceState: Bundle?) {
32 | inject()
33 | super.onCreate(savedInstanceState)
34 | setContentView(R.layout.activity_feature_three)
35 | Log.d("FeatureThreeActivity", databaseService.toString())
36 | Log.d("FeatureThreeActivity", networkService.toString())
37 | Log.d("FeatureThreeActivity", featureThreeObject.toString())
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/feature-three/src/main/java/com/ysfcyln/feature_three/FeatureThreeObject.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_three
2 |
3 | class FeatureThreeObject {
4 | }
--------------------------------------------------------------------------------
/feature-three/src/main/java/com/ysfcyln/feature_three/di/FeatureThreeComponent.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_three.di
2 |
3 | import com.ysfcyln.base.ActivityScope
4 | import com.ysfcyln.feature_three.FeatureThreeActivity
5 | import dagger.Subcomponent
6 |
7 | @ActivityScope
8 | @Subcomponent(
9 | modules = [
10 | // Bounded feature three activity necessary modules comes here
11 | FeatureThreeModule::class
12 | ]
13 | )
14 | interface FeatureThreeComponent {
15 |
16 | @Subcomponent.Factory
17 | interface Factory {
18 | fun create() : FeatureThreeComponent
19 | }
20 |
21 | fun inject(featureThreeActivity: FeatureThreeActivity) // Add feature three activity to Dagger graph
22 |
23 | }
--------------------------------------------------------------------------------
/feature-three/src/main/java/com/ysfcyln/feature_three/di/FeatureThreeComponentProvider.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_three.di
2 |
3 | interface FeatureThreeComponentProvider {
4 |
5 | fun provideFeatureThreeComponent() : FeatureThreeComponent
6 |
7 | }
--------------------------------------------------------------------------------
/feature-three/src/main/java/com/ysfcyln/feature_three/di/FeatureThreeModule.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_three.di
2 |
3 | import com.ysfcyln.feature_three.FeatureThreeObject
4 | import dagger.Module
5 | import dagger.Provides
6 |
7 | @Module
8 | class FeatureThreeModule {
9 |
10 | @Provides
11 | fun provideFeatureThreeObject() = FeatureThreeObject()
12 |
13 | }
--------------------------------------------------------------------------------
/feature-three/src/main/res/layout/activity_feature_three.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/feature-three/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature-three/src/test/java/com/ysfcyln/feature_three/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_three
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/feature-two/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/feature-two/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "29.0.2"
9 |
10 | defaultConfig {
11 | minSdkVersion 21
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles 'consumer-rules.pro'
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 |
32 | implementation project(":base")
33 | implementation project(":feature-three")
34 |
35 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
36 | implementation 'androidx.appcompat:appcompat:1.1.0'
37 | implementation 'androidx.core:core-ktx:1.2.0'
38 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
39 | testImplementation 'junit:junit:4.12'
40 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
41 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
42 |
43 | // Dagger dependencies
44 | implementation "com.google.dagger:dagger:$daggerVersion"
45 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
46 | }
47 |
--------------------------------------------------------------------------------
/feature-two/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/feature-two/consumer-rules.pro
--------------------------------------------------------------------------------
/feature-two/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/feature-two/src/androidTest/java/com/ysfcyln/feature_two/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_two
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.ysfcyln.feature_two.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/feature-two/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/feature-two/src/main/java/com/ysfcyln/feature_two/FeatureTwoActivity.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_two
2 |
3 | import android.content.Intent
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.util.Log
7 | import com.ysfcyln.base.DatabaseService
8 | import com.ysfcyln.base.NetworkService
9 | import com.ysfcyln.feature_three.FeatureThreeActivity
10 | import com.ysfcyln.feature_three.FeatureThreeObject
11 | import com.ysfcyln.feature_two.di.FeatureTwoComponentProvider
12 | import kotlinx.android.synthetic.main.activity_feature_two.*
13 | import javax.inject.Inject
14 |
15 | class FeatureTwoActivity : AppCompatActivity() {
16 |
17 | @Inject
18 | lateinit var databaseService: DatabaseService
19 |
20 | @Inject
21 | lateinit var networkService: NetworkService
22 |
23 | @Inject
24 | lateinit var featureTwoObject: FeatureTwoObject
25 |
26 | @Inject
27 | lateinit var featureThreeObject: FeatureThreeObject // Shared dependency
28 |
29 | /**
30 | * Create component and inject
31 | */
32 | private fun inject() {
33 | // When rotation happens component and its dependencies recreated :(
34 | val featureTwoComponent = (application as FeatureTwoComponentProvider).provideFeatureTwoComponent()
35 | featureTwoComponent.inject(this)
36 | }
37 |
38 | override fun onCreate(savedInstanceState: Bundle?) {
39 | inject()
40 | super.onCreate(savedInstanceState)
41 | setContentView(R.layout.activity_feature_two)
42 | Log.d("FeatureTwoActivity", databaseService.toString())
43 | Log.d("FeatureTwoActivity", networkService.toString())
44 | Log.d("FeatureTwoActivity", featureTwoObject.toString())
45 | Log.d("FeatureTwoActivity", featureThreeObject.toString())
46 |
47 | clickListeners()
48 | }
49 |
50 | /**
51 | * View click listeners
52 | */
53 | private fun clickListeners() {
54 | btnFeatureThree.setOnClickListener {
55 | startActivity(Intent(this, FeatureThreeActivity::class.java))
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/feature-two/src/main/java/com/ysfcyln/feature_two/FeatureTwoObject.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_two
2 |
3 | class FeatureTwoObject {
4 | }
--------------------------------------------------------------------------------
/feature-two/src/main/java/com/ysfcyln/feature_two/di/FeatureTwoComponent.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_two.di
2 |
3 | import com.ysfcyln.base.ActivityScope
4 | import com.ysfcyln.feature_two.FeatureTwoActivity
5 | import dagger.Subcomponent
6 |
7 | @ActivityScope
8 | @Subcomponent(
9 | modules = [
10 | // Bounded feature two activity necessary modules comes here
11 | FeatureTwoModule::class
12 | ]
13 | )
14 | interface FeatureTwoComponent {
15 |
16 | @Subcomponent.Factory
17 | interface Factory {
18 | fun create() : FeatureTwoComponent
19 | }
20 |
21 | fun inject(featureTwoActivity: FeatureTwoActivity) // Add feature two activity to Dagger graph
22 |
23 | }
--------------------------------------------------------------------------------
/feature-two/src/main/java/com/ysfcyln/feature_two/di/FeatureTwoComponentProvider.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_two.di
2 |
3 | interface FeatureTwoComponentProvider {
4 |
5 | fun provideFeatureTwoComponent() : FeatureTwoComponent
6 |
7 | }
--------------------------------------------------------------------------------
/feature-two/src/main/java/com/ysfcyln/feature_two/di/FeatureTwoModule.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_two.di
2 |
3 | import com.ysfcyln.feature_three.di.FeatureThreeModule
4 | import com.ysfcyln.feature_two.FeatureTwoObject
5 | import dagger.Module
6 | import dagger.Provides
7 |
8 | @Module(
9 | includes = [
10 | FeatureThreeModule::class
11 | ]
12 | )
13 | class FeatureTwoModule {
14 |
15 | @Provides
16 | fun provideFeatureTwoObject() = FeatureTwoObject()
17 |
18 | }
--------------------------------------------------------------------------------
/feature-two/src/main/res/layout/activity_feature_two.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
--------------------------------------------------------------------------------
/feature-two/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/feature-two/src/test/java/com/ysfcyln/feature_two/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.ysfcyln.feature_two
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yusufceylan/DaggerMultiModule/538d221ba107c0d029858cc8b099401efc461b9b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon May 25 11:44:30 EET 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='DaggerMultiModule'
2 | include ':app'
3 | include ':base'
4 | include ':feature-one'
5 | include ':feature-two'
6 | include ':feature-three'
7 |
--------------------------------------------------------------------------------