From 0e6cbe36298e56aafaeac1917df9e0282ae22f30 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 20 Jan 2024 15:57:21 +0900 Subject: [PATCH 01/17] [init] : .toml dependency build-logic module --- app/build.gradle.kts | 63 ++++--- app/src/main/AndroidManifest.xml | 13 +- .../java/com/moya/funch/SampleActivity.kt | 46 +++++ .../java/com/moya/funch/ui/theme/Color.kt | 11 ++ .../java/com/moya/funch/ui/theme/Theme.kt | 70 ++++++++ .../main/java/com/moya/funch/ui/theme/Type.kt | 34 ++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/themes.xml | 2 + build-logic/convention/build.gradle.kts | 54 ++++++ .../funch/plugins/AndroidApplicationPlugin.kt | 12 ++ .../funch/plugins/AndroidFeaturePlugin.kt | 12 ++ .../moya/funch/plugins/AndroidHiltPlugin.kt | 22 +++ .../moya/funch/plugins/AndroidKotlinPlugin.kt | 46 +++++ .../moya/funch/plugins/AndroidTestPlugin.kt | 41 +++++ .../com/moya/funch/plugins/CommonConfigs.kt | 48 +++++ .../com/moya/funch/plugins/ComposePlugin.kt | 28 +++ .../com/moya/funch/plugins/JUnit5Plugin.kt | 23 +++ .../plugins/KotlinSerializationPlugin.kt | 19 ++ .../moya/funch/plugins/utils/ProjectExts.kt | 9 + build-logic/gradle.properties | 4 + .../gradle/wrapper/gradle-wrapper.properties | 6 + build-logic/settings.gradle.kts | 14 ++ build.gradle.kts | 34 +++- gradle/libs.versions.toml | 167 +++++++++++++++++- settings.gradle.kts | 12 +- 25 files changed, 751 insertions(+), 40 deletions(-) create mode 100644 app/src/main/java/com/moya/funch/SampleActivity.kt create mode 100644 app/src/main/java/com/moya/funch/ui/theme/Color.kt create mode 100644 app/src/main/java/com/moya/funch/ui/theme/Theme.kt create mode 100644 app/src/main/java/com/moya/funch/ui/theme/Type.kt create mode 100644 build-logic/convention/build.gradle.kts create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidApplicationPlugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidFeaturePlugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidHiltPlugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidKotlinPlugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidTestPlugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/CommonConfigs.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/ComposePlugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/JUnit5Plugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/KotlinSerializationPlugin.kt create mode 100644 build-logic/convention/src/main/kotlin/com/moya/funch/plugins/utils/ProjectExts.kt create mode 100644 build-logic/gradle.properties create mode 100644 build-logic/gradle/wrapper/gradle-wrapper.properties create mode 100644 build-logic/settings.gradle.kts diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 44d96aeb..7f58de1c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,21 +1,19 @@ @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed plugins { - alias(libs.plugins.androidApplication) - alias(libs.plugins.kotlinAndroid) + alias(libs.plugins.punch.application) + alias(libs.plugins.punch.compose) +// alias(libs.plugins.google.services) +// alias(libs.plugins.app.distribution) +// alias(libs.plugins.crashlytics) } android { namespace = "com.moya.punch" - compileSdk = 34 defaultConfig { applicationId = "com.moya.punch" - minSdk = 28 - targetSdk = 34 - versionCode = 1 - versionName = "1.0" - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.appVersion.get() } buildTypes { @@ -23,25 +21,42 @@ android { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + "proguard-rules.pro", ) } } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = "1.8" - } } dependencies { + // feature +// implementation(projects.feature.profile) +// implementation(projects.feature.match) + +// implementation(libs.coil.core) + implementation(libs.startup) +// implementation(libs.security) + implementation(libs.splash.screen) - implementation(libs.core.ktx) - implementation(libs.appcompat) - implementation(libs.material) - testImplementation(libs.junit) - androidTestImplementation(libs.androidx.test.ext.junit) - androidTestImplementation(libs.espresso.core) -} \ No newline at end of file + // Google +// implementation(libs.google.android.gms) + + // Third Party + implementation(libs.coil.core) +// implementation(libs.kakao.login) + implementation(libs.bundles.retrofit) + implementation(libs.lifecycle) + implementation(libs.activity.compose) + implementation(platform(libs.compose.bom)) + implementation(libs.ui) + implementation(libs.ui.graphics) + implementation(libs.ui.tooling.preview) + implementation(libs.material3.compose) + androidTestImplementation(platform(libs.compose.bom)) + androidTestImplementation(libs.ui.test.junit4) + debugImplementation(libs.ui.tooling) + debugImplementation(libs.ui.test.manifest) + + // Firebase +// implementation(platform(libs.firebase)) +// implementation(libs.bundles.firebase) +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1b94fcee..100e2527 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,6 +11,17 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.PunchAOS" - tools:targetApi="31" /> + tools:targetApi="31"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/moya/funch/SampleActivity.kt b/app/src/main/java/com/moya/funch/SampleActivity.kt new file mode 100644 index 00000000..7c487261 --- /dev/null +++ b/app/src/main/java/com/moya/funch/SampleActivity.kt @@ -0,0 +1,46 @@ +package com.moya.funch + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.moya.funch.ui.theme.FunchAOSTheme + +class SampleActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + FunchAOSTheme { + // A surface container using the 'background' color from the theme + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + Greeting("Android") + } + } + } + } +} + +@Composable +fun Greeting(name: String, modifier: Modifier = Modifier) { + Text( + text = "Hello $name!", + modifier = modifier + ) +} + +@Preview(showBackground = true) +@Composable +fun GreetingPreview() { + FunchAOSTheme { + Greeting("Android") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/moya/funch/ui/theme/Color.kt b/app/src/main/java/com/moya/funch/ui/theme/Color.kt new file mode 100644 index 00000000..dff552fa --- /dev/null +++ b/app/src/main/java/com/moya/funch/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.moya.funch.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/app/src/main/java/com/moya/funch/ui/theme/Theme.kt b/app/src/main/java/com/moya/funch/ui/theme/Theme.kt new file mode 100644 index 00000000..b1b02fb2 --- /dev/null +++ b/app/src/main/java/com/moya/funch/ui/theme/Theme.kt @@ -0,0 +1,70 @@ +package com.moya.funch.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun FunchAOSTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/moya/funch/ui/theme/Type.kt b/app/src/main/java/com/moya/funch/ui/theme/Type.kt new file mode 100644 index 00000000..07a22848 --- /dev/null +++ b/app/src/main/java/com/moya/funch/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.moya.funch.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f52a3e67..4aba8fae 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ Punch-AOS + SampleActivity \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 201deacc..42b48642 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -13,4 +13,6 @@ ?attr/colorPrimaryVariant + +