Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/kotlin2.0 #13

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build
on:
push:
branches:
- main
- develop
pull_request:

concurrency:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build/
.externalNativeBuild
app/build
build
/.kotlin
23 changes: 23 additions & 0 deletions .run/spotlessApply.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spotlessApply" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--init-script=gradle/init.gradle.kts" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="spotlessApply" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>
27 changes: 5 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<h1 align="center">Breaking Bad - Jetpack Compose</h1>
<h1 align="center"> 🧪 Breaking Bad - Jetpack Compose</h1>

<p align="center">
<a href='https://developer.android.com'><img src='http://img.shields.io/badge/platform-android-green.svg'/></a>
<a href="https://kotlinlang.org/docs/whatsnew1920.html"><img src = "https://shields.io/badge/kotlin-1.9.23-blue" /></a>
<a href="https://developer.android.com/jetpack/compose/bom"><img src = "https://img.shields.io/badge/jetpack%20compose-2024.05.00-brightgreen" /></a>
<a href="https://kotlinlang.org/docs/whatsnew1920.html"><img src = "https://shields.io/badge/kotlin-2.0.10-blue" /></a>
<a href="https://developer.android.com/jetpack/compose/bom"><img src = "https://img.shields.io/badge/jetpack%20compose-2024.06.00-brightgreen" /></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg"/></a>
</p>

Expand Down Expand Up @@ -36,7 +36,7 @@
- [Coil-Compose](https://coil-kt.github.io/coil/compose)
- [Timber](https://github.com/JakeWharton/timber)
- [Haze](https://github.com/chrisbanes/haze)
- [sharedElement](https://developer.android.com/guide/fragments/animate#shared)
- [SharedElement](https://developer.android.com/guide/fragments/animate#shared)

## Multi Module

Expand All @@ -60,22 +60,5 @@
   └── setting
```

## Module Graphs
![](project.dot.png)

# License

```xml
Designed and developed by 2021 shinhyo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
49 changes: 0 additions & 49 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,52 +1,3 @@
plugins {
id("brba.android.application")
}

android {
namespace = "io.github.shinhyo.brba"

defaultConfig {
applicationId = "io.github.shinhyo.brba"
versionCode = 1
versionName = "1.0"
}

signingConfigs {
getByName("debug") {
storeFile = rootProject.file("debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}

buildTypes {
getByName("debug") {
isDebuggable = false
}

getByName("release") {
isDebuggable = false
isShrinkResources = true
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("debug")
}
}

buildFeatures {
buildConfig = true
}
}

dependencies {
implementation(project(":feature:main"))

implementation(libs.androidx.startup)
implementation(libs.androidx.compose.material3)
implementation(libs.timber)
implementation(libs.coil.kt)
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

<application
android:name=".BrBaApplication"
android:allowBackup="false"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_rules"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/colors.xml

This file was deleted.

13 changes: 13 additions & 0 deletions app/src/main/res/xml/backup_rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>
19 changes: 19 additions & 0 deletions app/src/main/res/xml/data_extraction_rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>
1 change: 1 addition & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tasks.withType<KotlinCompile>().configureEach {
dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.android.tools.common)
compileOnly(libs.compose.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.ksp.gradlePlugin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,66 @@ import com.android.build.api.dsl.ApplicationExtension
import io.github.shinhyo.brba.buildlogic.configureAndroidCompose
import io.github.shinhyo.brba.buildlogic.configureHiltAndroid
import io.github.shinhyo.brba.buildlogic.configureKotlinAndroid
import io.github.shinhyo.brba.buildlogic.findLibrary
import io.github.shinhyo.brba.buildlogic.findVersion

with(pluginManager) {
apply("com.android.application")
}

extensions.configure<ApplicationExtension> {
defaultConfig.targetSdk = findVersion("targetSdkVer").toString().toInt()
}
namespace = "io.github.shinhyo.brba"

defaultConfig.applicationId = "io.github.shinhyo.brba"
defaultConfig.targetSdk = findVersion("targetSdkVer").toInt()
defaultConfig.versionCode = findVersion("versionCode").toInt()
defaultConfig.versionName = findVersion("versionName")
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
defaultConfig.vectorDrawables.useSupportLibrary = true

buildFeatures.buildConfig = true

signingConfigs {
getByName("debug") {
storeFile = rootProject.file("debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}

buildTypes {
getByName("debug") {
isDebuggable = false
}

getByName("release") {
isDebuggable = false
isShrinkResources = true
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("debug")
}
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

configureKotlinAndroid()
configureAndroidCompose()
configureHiltAndroid()

dependencies {
add("implementation", project(":feature:main"))

configureKotlinAndroid()
configureAndroidCompose()
configureHiltAndroid()
add("implementation", findLibrary("androidx.startup"))
add("implementation", findLibrary("timber"))
add("implementation", findLibrary("coil.kt"))
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
package io.github.shinhyo.brba.buildlogic

import org.gradle.api.Project
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension

internal fun Project.configureAndroidCompose() {
androidExtension.apply {
buildFeatures {
compose = true
with(plugins) {
apply("org.jetbrains.kotlin.plugin.compose")
}

composeOptions {
kotlinCompilerExtensionVersion = findVersion("androidxComposeCompiler").toString()
buildFeatures {
compose = true
}

dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get()
add("implementation", platform(bom))
add("androidTestImplementation", platform(bom))
add("implementation", libs.findLibrary("androidx-compose-ui-tooling-preview").get())
add("debugImplementation", libs.findLibrary("androidx-compose-ui-tooling").get())
}

}

extensions.configure<ComposeCompilerGradlePluginExtension> {
enableStrongSkippingMode = true
includeSourceInformation = true
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ internal val Project.androidExtension: CommonExtension<*, *, *, *, *, *>
internal val Project.libs
get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")

internal fun Project.findVersion(alias: String) = libs.findVersion(alias).get()
internal fun Project.findVersion(alias: String) = libs.findVersion(alias).get().toString()

internal fun Project.findLibrary(alias: String) = libs.findLibrary(alias).get()
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ package io.github.shinhyo.brba.buildlogic

import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.kotlin.dsl.provideDelegate
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension

internal fun Project.configureKotlinAndroid() {
pluginManager.apply("org.jetbrains.kotlin.android")

androidExtension.apply {
compileSdk = findVersion("compileSdkVer").toString().toInt()
compileSdk = findVersion("compileSdkVer").toInt()

defaultConfig {
minSdk = findVersion("minSdkVer").toString().toInt()
minSdk = findVersion("minSdkVer").toInt()
}

compileOptions {
Expand All @@ -23,34 +28,32 @@ internal fun Project.configureKotlinAndroid() {
}
}

configureKotlin()
configureDependencies()
configureKotlin<KotlinAndroidProjectExtension>()
}

private fun Project.configureKotlin() {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
allWarningsAsErrors = properties["warningsAsErrors"] as? Boolean ?: false
compilerOptions.freeCompilerArgs.addAll(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:strongSkipping=true",
)
freeCompilerArgs = freeCompilerArgs + listOf(
private inline fun <reified T : KotlinTopLevelExtension> Project.configureKotlin() = configure<T> {
val warningsAsErrors: String? by project
when (this) {
is KotlinAndroidProjectExtension -> compilerOptions
is KotlinJvmProjectExtension -> compilerOptions
else -> TODO("Unsupported project extension $this ${T::class}")
}.apply {
jvmTarget = JvmTarget.JVM_17
allWarningsAsErrors = warningsAsErrors.toBoolean()
freeCompilerArgs.addAll(
listOf(
"-Xcontext-receivers",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
"-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
"-opt-in=androidx.compose.animation.ExperimentalSharedTransitionApi",
)
}
),
)
}
}

private fun Project.configureDependencies() {
dependencies {
add("coreLibraryDesugaring", findLibrary("android.desugarJdkLibs"))
add("implementation", findLibrary("kotlinx.coroutines.android"))
}
}
}
Loading
Loading