-
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.
기초적인 build-script를 구현합니다. (의존성 추가나 필요한 Plugin로직들은 차차 추가예정) - Gradle 빌드 시, 먼저 build-logic이라는 외부 Gradle 빌드 스크립트를 포함하도록 선언합니다. 해당 코드는 아래의 레포지토리를 참조했습니다. https://github.com/android/nowinandroid
- Loading branch information
1 parent
6f8c9ae
commit 726f922
Showing
15 changed files
with
247 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
plugins { | ||
id("kestrel.android.application") | ||
id("kestrel.android.hilt") | ||
} | ||
|
||
android { | ||
defaultConfig { | ||
applicationId = "com.toastmeister1.kestrel" | ||
targetSdk = 33 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = true | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
|
||
namespace = "com.toastmeister1.kestrel" | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.appcompat) | ||
implementation(libs.android.material) | ||
implementation(libs.androidx.constraintlayout) | ||
testImplementation(libs.junit4) | ||
androidTestImplementation(libs.androidx.test.ext) | ||
androidTestImplementation(libs.androidx.test.espresso.core) | ||
} |
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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/toastmeister1/kestrel/KestrelApplication.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,14 @@ | ||
package com.toastmeister1.kestrel | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
|
||
@HiltAndroidApp | ||
internal class KestrelApplication : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
} | ||
|
||
} |
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
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 @@ | ||
/build |
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 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "com.toastmeister1.kestrel.buildlogic" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.android.gradlePlugin) | ||
compileOnly(libs.kotlin.gradlePlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("androidApplication") { | ||
id = "kestrel.android.application" | ||
implementationClass = "AndroidApplicationConventionPlugin" | ||
} | ||
|
||
register("androidHilt") { | ||
id = "kestrel.android.hilt" | ||
implementationClass = "AndroidHiltConventionPlugin" | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
build-logic/convention/src/main/java/AndroidApplicationConventionPlugin.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,23 @@ | ||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.toastmeister1.convention.configureKotlinAndroid | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
class AndroidApplicationConventionPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.application") | ||
apply("org.jetbrains.kotlin.android") | ||
} | ||
|
||
extensions.configure<ApplicationExtension> { | ||
configureKotlinAndroid(this) | ||
defaultConfig.targetSdk = 33 | ||
} | ||
} | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
build-logic/convention/src/main/java/AndroidHiltConventionPlugin.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 @@ | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class AndroidHiltConventionPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("dagger.hilt.android.plugin") | ||
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()) | ||
} | ||
} | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
build-logic/convention/src/main/java/com/toastmeister1/convention/KotlinAndroid.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,44 @@ | ||
package com.toastmeister1.convention | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.ExtensionAware | ||
import org.gradle.kotlin.dsl.provideDelegate | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions | ||
|
||
|
||
/** | ||
* Configure base Kotlin with Android options | ||
*/ | ||
internal fun Project.configureKotlinAndroid( | ||
commonExtension: CommonExtension<*, *, *, *>, | ||
) { | ||
commonExtension.apply { | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
minSdk = 24 | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
kotlinOptions { | ||
freeCompilerArgs = freeCompilerArgs + listOf( | ||
"-opt-in=kotlin.RequiresOptIn", | ||
// Enable experimental coroutines APIs, including Flow | ||
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", | ||
"-opt-in=kotlin.Experimental" | ||
) | ||
|
||
jvmTarget = JavaVersion.VERSION_11.toString() | ||
} | ||
} | ||
} | ||
|
||
fun CommonExtension<*, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { | ||
(this as ExtensionAware).extensions.configure("kotlinOptions", block) | ||
} |
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 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic" | ||
include(":convention") |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
/** | ||
* version catalog 'libs' ISSUE(refer to the link) | ||
* https://github.com/gradle/gradle/issues/22797 | ||
*/ | ||
plugins { | ||
alias(libs.plugins.android.application) apply false | ||
alias(libs.plugins.android.library) apply false | ||
alias(libs.plugins.android.test) apply false | ||
alias(libs.plugins.kotlin.jvm) apply false | ||
alias(libs.plugins.kotlin.serialization) apply false | ||
alias(libs.plugins.hilt) apply false | ||
} |
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,39 @@ | ||
[versions] | ||
kotlin = "1.8.0" | ||
hilt = "2.44.2" | ||
androidGradlePlugin = "7.4.1" | ||
androidxCore = "1.9.0" | ||
androidxAppCompat = "1.6.1" | ||
androidxConstraintLayout = "2.1.4" | ||
androidxEspresso = "3.5.1" | ||
androidxTestExt = "1.1.5" | ||
junit4 = "4.13.2" | ||
material = "1.8.0" | ||
|
||
|
||
[libraries] | ||
android-material = { group = "com.google.android.material", name = "material", version.ref = "material" } | ||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } | ||
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" } | ||
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidxConstraintLayout" } | ||
androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidxEspresso" } | ||
androidx-test-ext = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidxTestExt" } | ||
junit4 = { group = "junit", name = "junit", version.ref = "junit4" } | ||
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } | ||
hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "hilt" } | ||
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" } | ||
|
||
# Dependencies of the included build-logic | ||
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } | ||
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } | ||
|
||
[bundles] | ||
|
||
|
||
[plugins] | ||
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } | ||
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } | ||
android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" } | ||
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } | ||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } | ||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } |
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,4 +1,5 @@ | ||
pluginManagement { | ||
includeBuild("build-logic") | ||
repositories { | ||
google() | ||
mavenCentral() | ||
|