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

build-logic 구현 #76

Merged
merged 1 commit into from
Nov 17, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ obj/
.idea/assetWizardSettings.xml
.idea/.gitignore
.idea/gradle.xml
.idea/codeStyles/

deploymentTargetDropDown.xml

Expand Down
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/release
.kotlin/

# Created by https://www.gitignore.io/api/kotlin,androidstudio
Expand Down
25 changes: 1 addition & 24 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.hilt.android)
alias(libs.plugins.kotlin.ksp)
id("missionmate.android.application")
}

android {
namespace = "com.goalpanzi.mission_mate"
compileSdk = 34

defaultConfig {
applicationId = "com.goalpanzi.mission_mate"
minSdk = 26
targetSdk = 34
versionCode = 5
versionName = "1.0.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
Expand All @@ -46,23 +40,6 @@ android {
isDebuggable = false
}
}
buildFeatures {
buildConfig = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions build-logic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
27 changes: 27 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.android.gradle.plugin)
implementation(libs.kotlin.gradle.plugin)
compileOnly(libs.ksp.gradle.plugin)
compileOnly(libs.compose.compiler.gradle.plugin)
}

gradlePlugin {
plugins {
register("androidApplication") {
id = "missionmate.android.application"
implementationClass = "MissionmateAndroidApplicationPlugin"
}
register("androidLibrary") {
id = "missionmate.android.library"
implementationClass = "MissionmateAndroidLibrary"
}
register("androidHilt") {
id = "missionmate.android.hilt"
implementationClass = "com.goalpanzi.mission_mate.convention.HiltAndroidPlugin"
}
}
}
14 changes: 14 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.goalpanzi.mission_mate.convention

import org.gradle.api.Project

fun Project.setNamespace(name: String) {
androidExtension.apply {
namespace = "com.goalpanzi.mission_mate.$name"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.goalpanzi.mission_mate.convention

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

internal fun Project.configureComposeAndroid() {
with(plugins) {
apply("org.jetbrains.kotlin.plugin.compose")
}

val libs = extensions.libs
androidExtension.apply {
buildFeatures {
compose = true
}

dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get()
implementation(platform(bom))
implementation(libs.findLibrary("androidx.ui").get())
implementation(libs.findLibrary("androidx.ui.graphics").get())
implementation(libs.findLibrary("androidx.ui.tooling.preview").get())
implementation(libs.findLibrary("androidx.material3").get())
implementation(libs.findLibrary("androidx.material").get())
implementation(libs.findLibrary("androidx.navigation.compose").get())
implementation(libs.findLibrary("androidx.hilt.navigation.compose").get())

debugImplementation(libs.findLibrary("androidx.ui.tooling").get())
debugImplementation(libs.findLibrary("androidx.ui.test.manifest").get())

androidTestImplementation(platform(bom))
androidTestImplementation(libs.findLibrary("androidx.ui.test.junit4").get())
}
}

extensions.getByType<ComposeCompilerGradlePluginExtension>().apply {
enableStrongSkippingMode.set(true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.goalpanzi.mission_mate.convention

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())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.goalpanzi.mission_mate.convention

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.artifacts.dsl.DependencyHandler
import org.gradle.api.plugins.ExtensionContainer
import org.gradle.kotlin.dsl.getByType

internal val ExtensionContainer.libs: VersionCatalog
get() = getByType<VersionCatalogsExtension>().named("libs")

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 Project.applicationExtension: CommonExtension<*, *, *, *, *, *>
get() = extensions.getByType<ApplicationExtension>()

internal val Project.libraryExtension: CommonExtension<*, *, *, *, *, *>
get() = extensions.getByType<LibraryExtension>()

internal fun DependencyHandler.implementation(dependencyNotation: Any) {
add("implementation", dependencyNotation)
}

internal fun DependencyHandler.testImplementation(dependencyNotation: Any) {
add("testImplementation", dependencyNotation)
}

internal fun DependencyHandler.androidTestImplementation(dependencyNotation: Any) {
add("androidTestImplementation", dependencyNotation)
}

internal fun DependencyHandler.debugImplementation(dependencyNotation: Any) {
add("debugImplementation", dependencyNotation)
}

internal fun DependencyHandler.ksp(dependencyNotation: Any) {
add("ksp", dependencyNotation)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.goalpanzi.mission_mate.convention

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("com.google.devtools.ksp")
}

val libs = extensions.libs
dependencies {
implementation(libs.findLibrary("hilt.android").get())
ksp(libs.findLibrary("hilt.compiler").get())
}
}

internal class HiltAndroidPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
configureHiltAndroid()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.goalpanzi.mission_mate.convention

import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

internal fun Project.configureKotlinAndroid() {

pluginManager.apply("org.jetbrains.kotlin.android")

androidExtension.apply {
compileSdk = 34

defaultConfig {
minSdk = 26
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
getByName("release") {
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

buildFeatures {
buildConfig = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.goalpanzi.mission_mate.convention

import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

internal fun Project.configureNetworkAndroid() {
val libs = extensions.libs

dependencies {
implementation(libs.findLibrary("retrofit").get())
implementation(libs.findLibrary("retrofit.kotlinx.serialization").get())
implementation(libs.findLibrary("okhttp3").get())
implementation(libs.findLibrary("okhttp3.logging.interceptor").get())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import com.goalpanzi.mission_mate.convention.configureHiltAndroid
import com.goalpanzi.mission_mate.convention.configureKotlinAndroid

plugins {
id("com.android.application")
}

configureKotlinAndroid()
configureHiltAndroid()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import com.goalpanzi.mission_mate.convention.configureComposeAndroid

configureComposeAndroid()
33 changes: 33 additions & 0 deletions build-logic/src/main/kotlin/missionmate.android.feature.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import com.goalpanzi.mission_mate.convention.configureHiltAndroid
import com.goalpanzi.mission_mate.convention.libs

plugins {
id("missionmate.android.library")
id("missionmate.android.compose")
}

android {
packaging {
resources {
excludes.add("META-INF/**")
}
}
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

}

configureHiltAndroid()

dependencies {
implementation(project(":core:designsystem"))
implementation(project(":core:navigation"))
implementation(project(":core:domain:user"))
implementation(project(":core:domain:setting"))
implementation(project(":core:domain:mission"))
implementation(project(":core:domain:common"))
implementation(project(":core:domain:auth"))
implementation(project(":core:ui"))

}
11 changes: 11 additions & 0 deletions build-logic/src/main/kotlin/missionmate.android.library.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import com.goalpanzi.mission_mate.convention.configureCoroutineAndroid
import com.goalpanzi.mission_mate.convention.configureHiltAndroid
import com.goalpanzi.mission_mate.convention.configureKotlinAndroid

plugins {
id("com.android.library")
}

configureKotlinAndroid()
configureCoroutineAndroid()
configureHiltAndroid()
Loading
Loading