Skip to content

Commit

Permalink
Merge pull request #46 from Akatsuki-USW/feature/compose-plugin
Browse files Browse the repository at this point in the history
Feature/compose plugin
  • Loading branch information
jinukeu authored Sep 19, 2023
2 parents c96efaf + ea1ca7e commit 0b1ad94
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 33 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.util.*

plugins {
id("buzzzzing.plugin.application")
id("buzzzzing.plugin.application.compose")
id("com.google.gms.google-services")
id("buzzzzing.plugin.hilt")
id("com.google.android.gms.oss-licenses-plugin")
Expand Down
16 changes: 12 additions & 4 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ dependencies {

gradlePlugin {
plugins {
register("AndroidApplicationPlugin") {
id = "buzzzzing.plugin.application"
implementationClass = "AndroidApplicationConventionPlugin"
}
register("AndroidApplicationComposePlugin") {
id = "buzzzzing.plugin.application.compose"
implementationClass = "AndroidApplicationComposeConventionPlugin"
}
register("JavaLibraryPlugin") {
id = "buzzzzing.plugin.java.library"
implementationClass = "JavaLibraryConventionPlugin"
Expand All @@ -26,12 +34,12 @@ gradlePlugin {
implementationClass = "AndroidHiltConventionPlugin"
}
register("AndroidLibraryPlugin") {
id = "buzzzzing.plugin.android-library"
id = "buzzzzing.plugin.android.library"
implementationClass = "AndroidLibraryConventionPlugin"
}
register("AndroidApplicationPlugin") {
id = "buzzzzing.plugin.application"
implementationClass = "AndroidApplicationConventionPlugin"
register("AndroidLibraryComposePlugin") {
id = "buzzzzing.plugin.android.library.compose"
implementationClass = "AndroidLibraryComposeConventionPlugin"
}
register("FeaturePlugin") {
id = "buzzzzing.plugin.feature"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@file:Suppress("unused")

import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import com.onewx2m.convention.configureAndroidCompose
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType

class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.application")
val extension = extensions.getByType<BaseAppModuleExtension>()
configureAndroidCompose(extension)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("unused")

import com.android.build.api.dsl.ApplicationExtension
import com.onewx2m.convention.configureKotlinAndroid
import org.gradle.api.Plugin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("unused")

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
Expand All @@ -8,17 +10,16 @@ class AndroidHiltConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.google.devtools.ksp")
apply("dagger.hilt.android.plugin")
// KAPT must go last to avoid build warnings.
// See: https://stackoverflow.com/questions/70550883/warning-the-following-options-were-not-recognized-by-any-processor-dagger-f
apply("org.jetbrains.kotlin.kapt")
}

val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
dependencies {
"implementation"(libs.findLibrary("hilt.android").get())
"kapt"(libs.findLibrary("hilt.compiler").get())
"kaptAndroidTest"(libs.findLibrary("hilt.compiler").get())
"ksp"(libs.findLibrary("hilt.compiler").get())
"testImplementation"(libs.findLibrary("hilt.testing").get())
"kspTest"(libs.findLibrary("hilt.testing.compiler").get())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@file:Suppress("unused")

import com.android.build.gradle.LibraryExtension
import com.onewx2m.convention.configureAndroidCompose
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType

class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.library")
val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@file:Suppress("unused")

import com.android.build.gradle.LibraryExtension
import com.onewx2m.convention.configureKotlinAndroid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("unused")

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
Expand All @@ -9,7 +11,7 @@ internal class FeatureConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("buzzzzing.plugin.android-library")
apply("buzzzzing.plugin.android.library")
apply("androidx.navigation.safeargs.kotlin")
apply("buzzzzing.plugin.hilt")
}
Expand Down Expand Up @@ -41,4 +43,4 @@ internal class FeatureConventionPlugin : Plugin<Project> {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("unused")

import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.onewx2m.convention

import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

internal fun Project.configureAndroidCompose(
commonExtension: CommonExtension<*, *, *, *, *>,
) {
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

commonExtension.apply {
buildFeatures.compose = true

composeOptions {
kotlinCompilerExtensionVersion = libs.findVersion("compose.compiler").get().requiredVersion
}
}

dependencies {
// Disabling to work with Alpha
"api"(platform(libs.findLibrary("compose-bom").get()))
"implementation"(libs.findBundle("compose").get())
"debugImplementation"(libs.findBundle("compose.debug").get())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *, *>,
) {
commonExtension.apply {
compileSdk = 33
compileSdk = 34

defaultConfig {
minSdk = 26
Expand Down
2 changes: 1 addition & 1 deletion core/core-ui/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("buzzzzing.plugin.android-library")
id("buzzzzing.plugin.android.library")
id("buzzzzing.plugin.hilt")
id("org.jetbrains.kotlin.plugin.serialization")
}
Expand Down
3 changes: 2 additions & 1 deletion design-system/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("buzzzzing.plugin.android-library")
id("buzzzzing.plugin.android.library")
id("buzzzzing.plugin.android.library.compose")
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.onewx2m.core_ui.extensions.onThrottleClick
import com.onewx2m.design_system.R
import com.onewx2m.design_system.databinding.ButtonMainBinding
Expand Down
2 changes: 1 addition & 1 deletion di/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("buzzzzing.plugin.android-library")
id("buzzzzing.plugin.android.library")
id("buzzzzing.plugin.hilt")
id("org.jetbrains.kotlin.plugin.serialization")
id("com.google.devtools.ksp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ import com.onewx2m.feature_login_signup.databinding.FragmentLoginBinding
import com.onewx2m.login_signup.util.KakaoLoginUtil
import com.onewx2m.mvi.MviFragment
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class LoginFragment : MviFragment<FragmentLoginBinding, LoginViewState, LoginEvent, LoginSideEffect, LoginViewModel>(
FragmentLoginBinding::inflate,
) {
class LoginFragment :
MviFragment<FragmentLoginBinding, LoginViewState, LoginEvent, LoginSideEffect, LoginViewModel>(
FragmentLoginBinding::inflate,
) {
override val viewModel: LoginViewModel by viewModels()

@Inject
lateinit var kakaoLoginUtil: KakaoLoginUtil
private val kakaoLoginUtil: KakaoLoginUtil by lazy {
KakaoLoginUtil()
}

override fun initView() {
binding.buttonKakao.onThrottleClick {
Expand All @@ -35,7 +36,8 @@ class LoginFragment : MviFragment<FragmentLoginBinding, LoginViewState, LoginEve
LoginSideEffect.TryLoginByKakao -> kakaoLogin()
LoginSideEffect.GoToHomeFragment -> goToHomeFragment()
is LoginSideEffect.GoToSignUpFragment -> goToSignUpFragment(sideEffect.signToken)
is LoginSideEffect.ShowErrorToast -> ErrorToast.make(binding.root, sideEffect.message).show()
is LoginSideEffect.ShowErrorToast -> ErrorToast.make(binding.root, sideEffect.message)
.show()
}

private fun kakaoLogin() {
Expand All @@ -47,7 +49,11 @@ class LoginFragment : MviFragment<FragmentLoginBinding, LoginViewState, LoginEve
}

private fun goToHomeFragment() {
val (request, navOptions) = DeepLinkUtil.getHomeRequestAndOption(requireContext(), R.id.loginFragment, true)
val (request, navOptions) = DeepLinkUtil.getHomeRequestAndOption(
requireContext(),
R.id.loginFragment,
true,
)
findNavController().navigate(request, navOptions)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import android.content.Context
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
import com.kakao.sdk.user.UserApiClient
import javax.inject.Inject

class KakaoLoginUtil @Inject constructor() {
class KakaoLoginUtil {

fun kakaoLogin(context: Context, onSuccess: (token: String) -> Unit, onFail: (error: Throwable?) -> Unit) {
// 카카오톡이 설치되어 있으면 카카오톡으로 로그인, 아니면 카카오계정으로 로그인
Expand Down
35 changes: 30 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
[versions]
androidGradlePlugin = "8.1.0"
androidGradlePlugin = "8.1.1"
android-core = "1.7.0"
appcompat = "1.5.1"
material = "1.9.0"
junit4 = "4.13.2"
espresso = "3.4.0"
ksp = "1.8.22-1.0.11"
ksp = "1.9.10-1.0.13"
googleService = "4.3.15"
firebaseBom = "31.2.0"

compose-compiler = "1.5.3"
compose-bom = "2023.09.00"
compose-material3 = "1.2.0-alpha07"
activity-compose = "1.7.2"
dagger-hilt-navigation-compose = "1.0.0"

androidxAppCompat = "1.6.1"
androidxCore = "1.10.1"
androidxLifecycle = "2.6.1"
Expand All @@ -20,15 +26,15 @@ androidxRecyclerView = "1.3.0"
androidxSplashScreen = "1.0.1"
androidxDataStore = "1.0.0"

kotlin = "1.8.22"
kotlin = "1.9.10"
kotlinxCoroutines = "1.7.1"
kotlinxSerializationJson = "1.5.1"

retrofit = "2.9.0"
retrofitKotlinxSerializationJson = "1.0.0"
okhttp = "4.11.0"

hilt = "2.46.1"
hilt = "2.48"
room = "2.5.2"

timber = "5.0.1"
Expand Down Expand Up @@ -63,9 +69,26 @@ kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-pl
ksp-gradlePlugin = { group = "com.google.devtools.ksp", name = "com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }
oss-gradlePlugin = { group = "com.google.android.gms", name = "oss-licenses-plugin", version.ref = "ossPlugin" }

# compose
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
ui = { group = "androidx.compose.ui", name = "ui" }
ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
ui-foundation = { group = "androidx.compose.foundation", name = "foundation" }
material3-compose = { group = "androidx.compose.material3", name = "material3" }
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivityKtx" }
lifecycle-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidxLifecycle" }
navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" }

hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
hilt-core = { group = "com.google.dagger", name = "hilt-core", version.ref = "hilt" }
hilt-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt" }
hilt-testing-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }

kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
Expand Down Expand Up @@ -122,4 +145,6 @@ oss = { group = "com.google.android.gms", name = "play-services-oss-licenses", v
firebase = ["firebase-analytics", "firebase-cloud-messaging"]
androidx-lifecycle = ["androidx-lifecycle-runtime-ktx", "androidx-lifecycle-viewmodel-ktx"]
androidx-navigation = ["navigation-fragment-ktx", "navigation-ui-ktx"]
coroutine = ["kotlinx-coroutines-android", "kotlinx-coroutines-core"]
coroutine = ["kotlinx-coroutines-android", "kotlinx-coroutines-core"]
compose = ["ui", "ui-graphics", "ui-tooling-preview", "material3-compose", "coil-compose", "ui-foundation", "activity-compose", "lifecycle-compose", "navigation-compose"]
compose-debug = ["ui-tooling", "ui-test-manifest" ]
2 changes: 1 addition & 1 deletion local/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("buzzzzing.plugin.android-library")
id("buzzzzing.plugin.android.library")
id("buzzzzing.plugin.hilt")
id("org.jetbrains.kotlin.plugin.serialization")
id("com.google.devtools.ksp")
Expand Down
1 change: 1 addition & 0 deletions local/src/main/java/com/onewx2m/local/RoomDataBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.onewx2m.local.model.SpotCategoryPref
SpotCategoryPref::class,
],
version = 1,
exportSchema = false,
)
abstract class RoomDataBase : RoomDatabase() {
abstract fun categoryDao(): CategoryDao
Expand Down
2 changes: 1 addition & 1 deletion mvi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("buzzzzing.plugin.android-library")
id("buzzzzing.plugin.android.library")
}

android {
Expand Down
2 changes: 1 addition & 1 deletion remote/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("buzzzzing.plugin.android-library")
id("buzzzzing.plugin.android.library")
id("buzzzzing.plugin.hilt")
id("org.jetbrains.kotlin.plugin.serialization")
}
Expand Down

0 comments on commit 0b1ad94

Please sign in to comment.