-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CaZaIt/feature/build-logic
[Feat] build logic 로직 및 프로젝트 기본 구성
- Loading branch information
Showing
45 changed files
with
1,549 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Android Pull Request CI | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
verify: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
checks: write | ||
|
||
# needed unless run with comment_mode: off | ||
pull-requests: write | ||
|
||
# only needed for private repository | ||
contents: read | ||
|
||
# only needed for private repository | ||
issues: read | ||
|
||
# required by download step to access artifacts API | ||
actions: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v3 | ||
|
||
- name: set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '17' | ||
|
||
- name: set up Android SDK | ||
uses: android-actions/setup-android@v2 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Run detekt | ||
run: ./gradlew detekt | ||
|
||
- name: Upload Event File | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Event File | ||
path: ${{ github.event_path }} | ||
|
||
- name: Run unit tests | ||
run: ./gradlew testDebugUnitTest --stacktrace | ||
|
||
- name: Upload Test Results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Test Results | ||
path: "**/test-results/**/*.xml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,29 @@ | ||
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed | ||
plugins { | ||
alias(libs.plugins.com.android.application) | ||
alias(libs.plugins.org.jetbrains.kotlin.android) | ||
id("cazait.android.application") | ||
id("com.google.android.gms.oss-licenses-plugin") | ||
} | ||
|
||
android { | ||
namespace = "org.cazait.cazaitandroid" | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
applicationId = "org.cazait.cazaitandroid" | ||
minSdk = 28 | ||
targetSdk = 33 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
buildTypes { | ||
getByName("release") { | ||
signingConfig = signingConfigs.getByName("debug") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.core.ktx) | ||
implementation(libs.appcompat) | ||
implementation(libs.material) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.test.ext.junit) | ||
androidTestImplementation(libs.espresso.core) | ||
} | ||
implementation(projects.core.navigation) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
`kotlin-dsl-precompiled-script-plugins` | ||
} | ||
|
||
dependencies { | ||
implementation(libs.android.gradlePlugin) | ||
implementation(libs.kotlin.gradlePlugin) | ||
implementation(libs.verify.detektPlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("androidHilt") { | ||
id = "cazait.android.hilt" | ||
implementationClass = "org.cazait.cazaitandroid.HiltAndroidPlugin" | ||
} | ||
register("kotlinHilt") { | ||
id = "cazait.kotlin.hilt" | ||
implementationClass = "org.cazait.cazaitandroid.HiltKotlinPlugin" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") | ||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
build-logic/src/main/kotlin/cazait.android.application.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import org.cazait.cazaitandroid.configureHiltAndroid | ||
import org.cazait.cazaitandroid.configureKotestAndroid | ||
import org.cazait.cazaitandroid.configureKotlinAndroid | ||
|
||
plugins { | ||
id("com.android.application") | ||
} | ||
|
||
configureKotlinAndroid() | ||
configureHiltAndroid() | ||
configureKotestAndroid() |
3 changes: 3 additions & 0 deletions
3
build-logic/src/main/kotlin/cazait.android.compose.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import org.cazait.cazaitandroid.configureComposeAndroid | ||
|
||
configureComposeAndroid() |
29 changes: 29 additions & 0 deletions
29
build-logic/src/main/kotlin/cazait.android.feature.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import org.cazait.cazaitandroid.configureHiltAndroid | ||
import org.cazait.cazaitandroid.libs | ||
|
||
plugins { | ||
id("cazait.android.library") | ||
id("cazait.android.compose") | ||
} | ||
|
||
android { | ||
defaultConfig { | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
} | ||
|
||
configureHiltAndroid() | ||
|
||
dependencies { | ||
implementation(project(":core:data")) | ||
implementation(project(":core:domain")) | ||
implementation(project(":core:navigation")) | ||
|
||
val libs = project.extensions.libs | ||
implementation(libs.findLibrary("hilt.navigation.compose").get()) | ||
implementation(libs.findLibrary("androidx.compose.navigation").get()) | ||
androidTestImplementation(libs.findLibrary("androidx.compose.navigation.test").get()) | ||
|
||
implementation(libs.findLibrary("androidx.lifecycle.viewModelCompose").get()) | ||
implementation(libs.findLibrary("androidx.lifecycle.runtimeCompose").get()) | ||
} |
14 changes: 14 additions & 0 deletions
14
build-logic/src/main/kotlin/cazait.android.library.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import org.cazait.cazaitandroid.configureCoroutineAndroid | ||
import org.cazait.cazaitandroid.configureHiltAndroid | ||
import org.cazait.cazaitandroid.configureKotest | ||
import org.cazait.cazaitandroid.configureKotlinAndroid | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("cazait.verify.detekt") | ||
} | ||
|
||
configureKotlinAndroid() | ||
configureKotest() | ||
configureCoroutineAndroid() | ||
configureHiltAndroid() |
10 changes: 10 additions & 0 deletions
10
build-logic/src/main/kotlin/cazait.kotlin.library.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import org.cazait.cazaitandroid.configureKotest | ||
import org.cazait.cazaitandroid.configureKotlin | ||
|
||
plugins { | ||
kotlin("jvm") | ||
id("cazait.verify.detekt") | ||
} | ||
|
||
configureKotlin() | ||
configureKotest() |
21 changes: 21 additions & 0 deletions
21
build-logic/src/main/kotlin/cazait.verify.detekt.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import org.cazait.cazaitandroid.configureVerifyDetekt | ||
|
||
configureVerifyDetekt() | ||
|
||
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach { | ||
// Target version of the generated JVM bytecode. It is used for type resolution. | ||
jvmTarget = JavaVersion.VERSION_17.majorVersion | ||
|
||
buildUponDefaultConfig = true // preconfigure defaults | ||
allRules = false // activate all available (even unstable) rules. | ||
parallel = true | ||
config.setFrom(listOf(file("$rootDir/config/detekt/detekt.yml"))) // point to your custom config defining rules to run, overwriting default behavior | ||
|
||
reports { | ||
file("$rootDir/build/reports/test/${project.name}/").mkdirs() | ||
html.required.set(true) // observe findings in your browser with structure and code snippets | ||
html.outputLocation.set(file("$rootDir/build/reports/detekt/${project.name}.html")) | ||
xml.required.set(true) // checkstyle like format mainly for integrations like Jenkins | ||
xml.outputLocation.set(file("$rootDir/build/reports/detekt/${project.name}.xml")) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
build-logic/src/main/kotlin/org/cazait/cazaitandroid/ComposeAndroid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.cazait.cazaitandroid | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureComposeAndroid() { | ||
val libs = extensions.libs | ||
androidExtension.apply { | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = | ||
libs.findVersion("androidxComposeCompiler").get().toString() | ||
} | ||
|
||
dependencies { | ||
val bom = libs.findLibrary("androidx-compose-bom").get() | ||
add("implementation", platform(bom)) | ||
add("androidTestImplementation", platform(bom)) | ||
|
||
add("implementation", libs.findLibrary("androidx.compose.material3").get()) | ||
add("implementation", libs.findLibrary("androidx.compose.ui").get()) | ||
add("implementation", libs.findLibrary("androidx.compose.ui.tooling.preview").get()) | ||
add("androidTestImplementation", libs.findLibrary("androidx.test.ext").get()) | ||
add("androidTestImplementation", libs.findLibrary("androidx.test.espresso.core").get()) | ||
add("androidTestImplementation", libs.findLibrary("androidx.compose.ui.test").get()) | ||
add("debugImplementation", libs.findLibrary("androidx.compose.ui.tooling").get()) | ||
add("debugImplementation", libs.findLibrary("androidx.compose.ui.testManifest").get()) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
build-logic/src/main/kotlin/org/cazait/cazaitandroid/CoroutineAndroid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.cazait.cazaitandroid | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureCoroutineAndroid() { | ||
val libs = extensions.libs | ||
configureCoroutineKotlin() | ||
dependencies { | ||
"implementation"(libs.findLibrary("coroutines.android").get()) | ||
} | ||
} | ||
|
||
internal fun Project.configureCoroutineKotlin() { | ||
val libs = extensions.libs | ||
dependencies { | ||
"implementation"(libs.findLibrary("coroutines.core").get()) | ||
"testImplementation"(libs.findLibrary("coroutines.test").get()) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
build-logic/src/main/kotlin/org/cazait/cazaitandroid/Extension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.cazait.cazaitandroid | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.android.build.api.dsl.CommonExtension | ||
import com.android.build.api.dsl.LibraryExtension | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.api.plugins.ExtensionContainer | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
internal val Project.applicationExtension: CommonExtension<*, *, *, *, *> | ||
get() = extensions.getByType<ApplicationExtension>() | ||
|
||
internal val Project.libraryExtension: CommonExtension<*, *, *, *, *> | ||
get() = extensions.getByType<LibraryExtension>() | ||
|
||
internal val Project.androidExtension: CommonExtension<*, *, *, *, *> | ||
get() = runCatching { libraryExtension } | ||
.recoverCatching { applicationExtension } | ||
.onFailure { println("Could not find Library or Application extension from this project") } | ||
.getOrThrow() | ||
|
||
internal val ExtensionContainer.libs: VersionCatalog | ||
get() = getByType<VersionCatalogsExtension>().named("libs") |
28 changes: 28 additions & 0 deletions
28
build-logic/src/main/kotlin/org/cazait/cazaitandroid/HiltAndroid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.cazait.cazaitandroid | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureHiltAndroid() { | ||
with(pluginManager) { | ||
apply("dagger.hilt.android.plugin") | ||
apply("org.jetbrains.kotlin.kapt") | ||
} | ||
|
||
val libs = extensions.libs | ||
dependencies { | ||
"implementation"(libs.findLibrary("hilt.android").get()) | ||
"kapt"(libs.findLibrary("hilt.android.compiler").get()) | ||
"kaptAndroidTest"(libs.findLibrary("hilt.android.compiler").get()) | ||
} | ||
} | ||
|
||
internal class HiltAndroidPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
configureHiltAndroid() | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
build-logic/src/main/kotlin/org/cazait/cazaitandroid/HiltKotlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.cazait.cazaitandroid | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
internal fun Project.configureHiltKotlin() { | ||
with(pluginManager) { | ||
apply("org.jetbrains.kotlin.kapt") | ||
} | ||
|
||
val libs = extensions.libs | ||
dependencies { | ||
"implementation"(libs.findLibrary("hilt.core").get()) | ||
"kapt"(libs.findLibrary("hilt.compiler").get()) | ||
} | ||
} | ||
|
||
internal class HiltKotlinPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
configureHiltKotlin() | ||
} | ||
} | ||
} |
Oops, something went wrong.