Skip to content

Commit a59d36d

Browse files
authored
Merge pull request #8 from KryptKode/develop
Develop
2 parents 9b73af9 + 69dbf8c commit a59d36d

File tree

18 files changed

+403
-77
lines changed

18 files changed

+403
-77
lines changed

.cloc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
app/src
2+
common/androidShared/src
3+
common/testShared/src
4+
core/src
5+
libs/basemvi/src
6+
features/users/src

.codecov/config.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
codecov:
2+
notify:
3+
require_ci_to_pass: yes
4+
5+
coverage:
6+
precision: 2
7+
round: down
8+
range: 60..100
9+
status:
10+
project:
11+
default:
12+
enabled: yes
13+
target: auto
14+
threshold: 2
15+
patch:
16+
default:
17+
enabled: yes
18+
target: auto
19+
threshold: 2
20+
changes: no
21+
22+
parsers:
23+
gcov:
24+
branch_detection:
25+
conditional: yes
26+
loop: yes
27+
method: no
28+
macro: no
29+
30+
comment:
31+
layout: "header,reach,diff,flags,files"
32+
behavior: default
33+
require_changes: no

.github/workflows/android.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ jobs:
2222
with:
2323
java-version: 1.8
2424

25+
- name: Decode API app-id
26+
env:
27+
DUMMY_API_ID: ${{ secrets.DUMMY_API_ID }}
28+
run: echo dummy.api.app.id="DUMMY_API_ID" >> ./local.properties
29+
2530
- uses: actions/cache@v2
2631
with:
2732
path: ~/.gradle
@@ -41,6 +46,11 @@ jobs:
4146
with:
4247
java-version: 1.8
4348

49+
- name: Decode API app-id
50+
env:
51+
DUMMY_API_ID: ${{ secrets.DUMMY_API_ID }}
52+
run: echo dummy.api.app.id="DUMMY_API_ID" >> ./local.properties
53+
4454
- uses: actions/cache@v2
4555
with:
4656
path: ~/.gradle
@@ -61,6 +71,11 @@ jobs:
6171
with:
6272
java-version: 1.8
6373

74+
- name: Decode API app-id
75+
env:
76+
DUMMY_API_ID: ${{ secrets.DUMMY_API_ID }}
77+
run: echo dummy.api.app.id="DUMMY_API_ID" >> ./local.properties
78+
6479
- uses: actions/cache@v2
6580
with:
6681
path: ~/.gradle
@@ -81,6 +96,11 @@ jobs:
8196
with:
8297
java-version: 1.8
8398

99+
- name: Decode API app-id
100+
env:
101+
DUMMY_API_ID: ${{ secrets.DUMMY_API_ID }}
102+
run: echo dummy.api.app.id="DUMMY_API_ID" >> ./local.properties
103+
84104
- uses: actions/cache@v2
85105
with:
86106
path: ~/.gradle
@@ -91,11 +111,21 @@ jobs:
91111
- name: Run Unit Tests
92112
run: ./gradlew testDebugUnitTest
93113

114+
- name: Upload test reports
115+
uses: actions/upload-artifact@v2
116+
if: failure()
117+
with:
118+
name: core-unit-test-report
119+
path: |
120+
core/build/reports/tests/testDebugUnitTest
121+
features/users/build/reports/tests/testDebugUnitTest
122+
app/build/reports/tests/testDebugUnitTest
123+
94124
- name: Generate Code Coverage
95125
run: ./gradlew jacocoTestReportDebug
96126

97127
- name: Upload coverage to Codecov
98128
uses: codecov/codecov-action@v1
99129
with:
100130
flags: unittests
101-
fail_ci_if_error: true
131+
fail_ci_if_error: true

README.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
[![Actions Status](https://github.com/KryptKode/AndroidMultiModuleTemplate/workflows/android/badge.svg)](https://github.com/KryptKode/AndroidMultiModuleTemplate/actions)
2+
[![codecov](https://codecov.io/gh/KryptKode/AndroidMultiModuleTemplate/branch/master/graph/badge.svg?token=3L2WH4293M)](https://codecov.io/gh/KryptKode/AndroidMultiModuleTemplate)
3+
[![Kotlin Version](https://img.shields.io/badge/kotlin-1.4.21-blue.svg)](http://kotlinlang.org/)
4+
[![AGP](https://img.shields.io/badge/AGP-4.1.0-blue)](https://developer.android.com/studio/releases/gradle-plugin)
5+
[![Gradle](https://img.shields.io/badge/Gradle-6.5-blue)](https://gradle.org)
6+
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
7+
18
# Android Multi-Module Template
29

310
[![Actions Status](https://github.com/KryptKode/AndroidMultiModuleTemplate/workflows/android/badge.svg)](https://github.com/KryptKode/AndroidMultiModuleTemplate/actions)
@@ -10,29 +17,42 @@ A template for bootstrapping a multi-module android project. It demonstrates cle
1017

1118
## Top things to learn here
1219

13-
- Multi-module clean architecture
14-
- Kotlin coroutines with Flow
15-
- Dependency injection with Dagger-Hilt
16-
- Unit testing
17-
- View abstracted from Fragment
18-
- API request with Retrofit
19-
- CI/CD with Github actions
20+
- Multi-module [clean architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
21+
- Kotlin coroutines with [Flow]()
22+
- Dependency injection with [Dagger-Hilt](https://dagger.dev/hilt/)
23+
- View abstracted from Fragment like [componentizationArch](https://github.com/julianomoraes/componentizationArch)
24+
- API request with [Retrofit](http://square.github.io/retrofit) and [Moshi](https://github.com/square/moshi) for JSON serialisation and deserialization
25+
- Local persistence with [Room](https://developer.android.com/topic/libraries/architecture/room)
26+
- Paging with [Paging 3.0](https://developer.android.com/topic/libraries/architecture/paging/v3-overview)
27+
- CI with [Github actions](https://github.com/features/actions)
28+
- Code coverage with [jacoco](https://github.com/vanniktech/gradle-android-junit-jacoco-plugin) with reports uploaded to [codecov](https://codecov.io/gh/KryptKode/DroidArch/)
2029
- Code lint check with [Ktlint](https://github.com/pinterest/ktlint) using a [gradle plugin](https://github.com/JLLeitschuh/ktlint-gradle)
2130
- Static code analysis with [detekt](https://github.com/detekt/detekt)
2231
- Dependency management with [buildSrc](https://gradle.org/kotlin/) (Kotlin DSL)
2332
- Dependency updates with [buildSrcVersions](https://jmfayard.github.io/refreshVersions/)
33+
- [Git hooks](https://github.com/KryptKode/DroidArch/tree/master/scripts/git-hooks) to perform ktlint, detekt and lint checks before committing
2434

2535
## Libraries
2636

2737
- [Material Components](https://github.com/material-components/material-components-android/)
2838
- [Constraint Layout](https://developer.android.com/reference/android/support/constraint/ConstraintLayout)
2939
- [Retrofit](http://square.github.io/retrofit) for REST api communication
40+
- [Moshi](https://github.com/square/moshi) for JSON serialisation and deserialization
3041
- [Mockk](https://github.com/mockk/mockk) for mocking in tests
31-
- [Dagger2](https://github.com/google/dagger) for dependency injection
42+
- [Dagger-Hilt](https://dagger.dev/hilt/) for dependency injection
3243
- [Kotlin Flow](https://kotlinlang.org/docs/reference/coroutines/flow.html) for concurrency
44+
- [Turbine](https://github.com/cashapp/turbine) for testing flow
3345
- [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) & [LiveData](https://developer.android.com/topic/libraries/architecture/livedata)
3446
- [Navigation Architecture Component](https://developer.android.com/guide/navigation/navigation-getting-started)
47+
- [Room](https://developer.android.com/topic/libraries/architecture/room) for database
48+
- [Glide](https://github.com/bumptech/glide) for image loading
3549
- [ViewBinding](https://developer.android.com/topic/libraries/view-binding)
3650
- [Kotlin Delegates](https://kotlinlang.org/docs/reference/delegated-properties.html)
3751
- [Ktlint gradle plugin](https://github.com/JLLeitschuh/ktlint-gradle) for code lint checks
3852
- [Detekt](https://github.com/detekt/detekt) for static code analysis
53+
- [LeakCanary](https://github.com/square/leakcanary) for detecting memory leaks in development
54+
55+
56+
### Extras
57+
58+
The gradle script uses Kotlin Gradle DSL ([buildSrc](https://gradle.org/kotlin/) ) which brings Kotlin's rich language features to gradle configuration. The project also uses detekt to detect code smells and ktlint to enforce proper code style. Github actions handles continuous integration, and runs detekt, ktlint, lint and unit tests concurrently. A pre-commit git hook verifies the project's code style before committing code. Test coverage reports are uploaded to [codecov]().

app/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ android {
3131
kotlinOptions {
3232
jvmTarget = "1.8"
3333
}
34+
35+
compileOptions {
36+
sourceCompatibility = JavaVersion.VERSION_1_8
37+
targetCompatibility = JavaVersion.VERSION_1_8
38+
}
3439
}
3540

3641
dependencies {

build.gradle.kts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ buildscript {
1313
classpath(Libs.com_android_tools_build_gradle)
1414
classpath(Libs.kotlin_gradle_plugin)
1515
classpath(Libs.hilt_android_gradle_plugin)
16+
classpath(Libs.navigation_safe_args_gradle_plugin)
1617
}
1718
}
1819

@@ -32,12 +33,16 @@ allprojects {
3233

3334
tasks.withType<KotlinCompile>().configureEach {
3435
kotlinOptions.freeCompilerArgs +=
35-
"-Xuse-experimental=" +
36-
"kotlin.Experimental," +
37-
"kotlinx.coroutines.ExperimentalCoroutinesApi," +
38-
"kotlinx.coroutines.InternalCoroutinesApi," +
39-
"kotlinx.coroutines.ObsoleteCoroutinesApi," +
40-
"kotlinx.coroutines.FlowPreview"
36+
listOf(
37+
"-Xuse-experimental=kotlin.Experimental",
38+
"-Xopt-in=kotlin.time.ExperimentalTime",
39+
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
40+
"-Xopt-in=kotlin.RequiresOptIn",
41+
"-Xopt-in=kotlinx.coroutines.ObsoleteCoroutinesApi",
42+
"-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi",
43+
"-Xopt-in=kotlinx.coroutines.FlowPreview",
44+
"-Xopt-in=androidx.paging.ExperimentalPagingApi"
45+
)
4146
}
4247
}
4348

buildSrc/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ object Dependencies {
1919
const val detektGradlePlugin = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0"
2020
const val klintGradlePlugin = "org.jlleitschuh.gradle:ktlint-gradle:9.4.1"
2121
const val daggerHilt = "com.google.dagger:hilt-android-gradle-plugin:2.28.3-alpha"
22+
const val navigationSafeArgs = "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.2"
2223
const val jacoco = "com.vanniktech:gradle-android-junit-jacoco-plugin:0.16.0"
2324
}
2425

@@ -28,5 +29,6 @@ dependencies {
2829
implementation(Dependencies.detektGradlePlugin)
2930
implementation(Dependencies.klintGradlePlugin)
3031
implementation(Dependencies.daggerHilt)
32+
implementation(Dependencies.navigationSafeArgs)
3133
implementation(Dependencies.jacoco)
32-
}
34+
}

buildSrc/src/main/kotlin/BuildModules.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object BuildModules {
1010
const val home = ":features:home"
1111
}
1212

13-
object Commons {
13+
object Common {
1414
const val testShared = ":common:testShared"
1515
const val androidShared = ":common:androidShared"
1616
}

0 commit comments

Comments
 (0)