Skip to content

Commit d270b31

Browse files
authored
Merge pull request #6 from shinhyo/develop
Gradle Version Catalog
2 parents 04cf71f + 2c6acc7 commit d270b31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+937
-407
lines changed

.github/ci-gradle.properties

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Copyright 2020 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
org.gradle.daemon=false
17+
org.gradle.parallel=true
18+
org.gradle.workers.max=2
19+
kotlin.incremental=false
20+
kotlin.compiler.execution.strategy=in-process
21+
# Controls KotlinOptions.allWarningsAsErrors.
22+
# This value used in CI and is currently set to false.
23+
# If you want to treat warnings as errors locally, set this property to true
24+
# in your ~/.gradle/gradle.properties file.
25+
warningsAsErrors=false

.github/workflows/Build.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
concurrency:
9+
group: build-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 60
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Validate Gradle Wrapper
22+
uses: gradle/wrapper-validation-action@v1
23+
24+
- name: Copy CI gradle.properties
25+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
26+
27+
- name: Set up JDK 11
28+
uses: actions/setup-java@v3
29+
with:
30+
distribution: 'zulu'
31+
java-version: 11
32+
33+
- name: Setup Gradle
34+
uses: gradle/gradle-build-action@v2
35+
36+
- name: Check spotless
37+
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
38+
39+
- name: Check lint
40+
run: ./gradlew lintDebug --stacktrace
41+
42+
- name: Build all build type and flavor permutations
43+
run: ./gradlew assemble --stacktrace
44+
45+
# - name: Run local tests
46+
# run: ./gradlew testDebug testProdDebug --stacktrace
47+
48+
- name: Upload build outputs (APKs)
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: build-outputs
52+
path: app/build/outputs
53+
54+
- name: Upload build reports
55+
if: always()
56+
uses: actions/upload-artifact@v3
57+
with:
58+
name: build-reports
59+
path: app/build/reports

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Breaking Bad - Jetpack Compose
22
<a href='https://developer.android.com'><img src='http://img.shields.io/badge/platform-android-green.svg'/></a>
3-
<a href = "https://developer.android.com/jetpack/androidx/versions/all-channel#march_24_2021"> <img src = "https://img.shields.io/badge/Jetpack%20Compose-1.1.1-brightgreen" /> </a>
3+
<a href = "https://developer.android.com/jetpack/androidx/versions/all-channel#march_24_2021"> <img src = "https://img.shields.io/badge/Jetpack%20Compose-1.2.1-brightgreen" /> </a>
44
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"/></a>
55
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)
66

@@ -26,9 +26,10 @@
2626
- Material Design
2727
- Single Activity
2828
- StaggeredVerticalGrid
29+
- [Gradle Version Catalog](https://docs.gradle.org/7.4/userguide/platforms.html)
2930
- [Accompanist](https://google.github.io/accompanist)
3031
- [Retrofit2](https://github.com/square/retrofit)
31-
- [Glide](https://bumptech.github.io/glide/)
32+
- [Coil-Compose](https://coil-kt.github.io/coil/compose)
3233
- [Timber](https://github.com/JakeWharton/timber)
3334

3435
## Multi Module (Clean Architecture)

app/build.gradle.kts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
plugins {
2-
id("com.android.application")
3-
kotlin("android")
4-
kotlin("kapt")
5-
id("dagger.hilt.android.plugin")
2+
id("brba.android.application")
3+
id("brba.android.application.compose")
4+
id("brba.android.hilt")
65
}
76

87
android {
8+
namespace = "io.github.shinhyo.brba"
99

1010
defaultConfig {
1111
applicationId = "io.github.shinhyo.brba"
12-
versionCode = Versions.versionCode
13-
versionName = Versions.versionName
12+
versionCode = 1
13+
versionName = "1.0"
1414
}
1515

1616
buildTypes {
1717
getByName("release") {
1818
isMinifyEnabled = false
1919
proguardFiles(
20-
getDefaultProguardFile(
21-
"proguard-android-optimize.txt"
22-
),
20+
getDefaultProguardFile("proguard-android-optimize.txt"),
2321
"proguard-rules.pro"
2422
)
2523
}
2624
}
27-
28-
buildFeatures {
29-
compose = true
30-
}
31-
composeOptions {
32-
kotlinCompilerExtensionVersion = Dep.AndroidX.Compose.version
33-
}
3425
}
3526

3627
dependencies {
@@ -39,17 +30,14 @@ dependencies {
3930
implementation(project(":domain"))
4031
implementation(project(":data"))
4132

42-
implementation(Dep.Google.material)
43-
44-
implementation(Dep.AndroidX.startupRuntime)
33+
implementation(libs.material)
4534

46-
implementation(Dep.AndroidX.core)
47-
implementation(Dep.AndroidX.appcompat)
48-
implementation(Dep.AndroidX.Activity.compose)
35+
implementation(libs.androidx.startup)
4936

50-
implementation(Dep.Dagger.hiltAndroid)
51-
kapt(Dep.Dagger.hiltCompiler)
37+
implementation(libs.androidx.core.ktx)
38+
implementation(libs.androidx.appcompat)
39+
implementation(libs.androidx.activity.compose)
5240

53-
implementation(Dep.timber)
41+
implementation(libs.timber)
5442

5543
}

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="io.github.shinhyo.brba">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<uses-permission android:name="android.permission.INTERNET" />
76

87
<application
98
android:name=".app.BrBaApp"
109
android:allowBackup="true"
10+
android:hardwareAccelerated="true"
1111
android:icon="@mipmap/ic_launcher"
1212
android:label="@string/app_name"
1313
android:largeHeap="true"
1414
android:supportsRtl="true"
15-
android:hardwareAccelerated="true"
1615
android:theme="@style/Theme.BrBaCompose">
1716
<activity
1817
android:name=".app.ui.MainActivity"
1918
android:exported="true"
20-
android:label="@string/app_name"
2119
android:theme="@style/Theme.BrBaCompose.NoActionBar">
2220
<intent-filter>
2321
<action android:name="android.intent.action.MAIN" />
@@ -27,11 +25,11 @@
2725
</activity>
2826
<provider
2927
android:name="androidx.startup.InitializationProvider"
30-
android:authorities="${applicationId}.androidx-startup"
28+
android:authorities="io.github.shinhyo.brba.androidx-startup"
3129
android:exported="false"
3230
tools:node="merge">
3331
<meta-data
34-
android:name="${applicationId}.app.initializer.TimberInitializer"
32+
android:name="io.github.shinhyo.brba.app.initializer.TimberInitializer"
3533
android:value="androidx.startup" />
3634
</provider>
3735
</application>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2022 shinhyo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.shinhyo.brba.app.di
17+
18+
import dagger.Module
19+
import dagger.Provides
20+
import dagger.hilt.InstallIn
21+
import dagger.hilt.components.SingletonComponent
22+
import io.github.shinhyo.brba.domain.di.DefaultDispatcher
23+
import io.github.shinhyo.brba.domain.di.IoDispatcher
24+
import io.github.shinhyo.brba.domain.di.MainDispatcher
25+
import io.github.shinhyo.brba.domain.di.MainImmediateDispatcher
26+
import kotlinx.coroutines.CoroutineDispatcher
27+
import kotlinx.coroutines.Dispatchers
28+
29+
@InstallIn(SingletonComponent::class)
30+
@Module
31+
internal object CoroutinesModule {
32+
@DefaultDispatcher
33+
@Provides
34+
fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
35+
36+
@IoDispatcher
37+
@Provides
38+
fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
39+
40+
@MainDispatcher
41+
@Provides
42+
fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
43+
44+
@MainImmediateDispatcher
45+
@Provides
46+
fun providesMainImmediateDispatcher(): CoroutineDispatcher = Dispatchers.Main.immediate
47+
}

app/src/main/res/drawable/brba.png

-5.32 KB
Binary file not shown.

app/src/main/res/values/themes.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<resources xmlns:tools="http://schemas.android.com/tools">
1+
<resources>
22
<!-- Base application theme. -->
33
<style name="Theme.BrBaCompose" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
44
<!-- Primary brand color. -->
@@ -10,7 +10,7 @@
1010
<!-- <item name="colorSecondaryVariant">@color/teal_700</item>-->
1111
<!-- <item name="colorOnSecondary">@color/black</item>-->
1212
<!-- Status bar color. -->
13-
<item name="android:statusBarColor" tools:targetApi="l">@color/immersive_sys_ui</item>
13+
<item name="android:statusBarColor">@color/immersive_sys_ui</item>
1414
<!-- Customize your theme here. -->
1515
</style>
1616

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
group = "io.github.shinhyo.brba.buildlogic"
6+
7+
java {
8+
sourceCompatibility = JavaVersion.VERSION_1_8
9+
targetCompatibility = JavaVersion.VERSION_1_8
10+
}
11+
12+
dependencies {
13+
compileOnly(libs.android.gradlePlugin)
14+
compileOnly(libs.kotlin.gradlePlugin)
15+
}
16+
17+
gradlePlugin {
18+
plugins {
19+
register("androidApplication") {
20+
id = "brba.android.application"
21+
implementationClass = "AndroidApplicationConventionPlugin"
22+
}
23+
register("androidApplicationCompose") {
24+
id = "brba.android.application.compose"
25+
implementationClass = "AndroidApplicationComposeConventionPlugin"
26+
}
27+
28+
register("androidHilt") {
29+
id = "brba.android.hilt"
30+
implementationClass = "AndroidHiltConventionPlugin"
31+
}
32+
33+
register("androidLibrary") {
34+
id = "brba.android.library"
35+
implementationClass = "AndroidLibraryConventionPlugin"
36+
}
37+
register("androidLibraryCompose") {
38+
id = "brba.android.library.compose"
39+
implementationClass = "AndroidLibraryComposeConventionPlugin"
40+
}
41+
42+
}
43+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import com.android.build.api.dsl.ApplicationExtension
2+
import io.github.shinhyo.brba.buildlogic.configureAndroidCompose
3+
import org.gradle.api.Plugin
4+
import org.gradle.api.Project
5+
import org.gradle.kotlin.dsl.getByType
6+
7+
class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
8+
override fun apply(target: Project) {
9+
with(target) {
10+
pluginManager.apply("com.android.application")
11+
val extension = extensions.getByType<ApplicationExtension>()
12+
configureAndroidCompose(extension)
13+
}
14+
}
15+
16+
}

0 commit comments

Comments
 (0)