-
Notifications
You must be signed in to change notification settings - Fork 1
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 Team-HMH/setting/build_logic
[setting]: build-logic 추가 작업
- Loading branch information
Showing
21 changed files
with
371 additions
and
9 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
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,5 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="Theme.HMHAndroid" parent="Theme.AppCompat.Light.NoActionBar" /> | ||
</resources> |
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,54 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "com.hmh.hamyeonham.buildlogic" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
|
||
dependencies { | ||
compileOnly(libs.agp) | ||
compileOnly(libs.kotlin.gradleplugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
create("android-application") { | ||
id = "com.hmh.hamyeonham.application" | ||
implementationClass = "com.hmh.hamyeonham.plugin.AndroidApplicationPlugin" | ||
} | ||
create("android-feature") { | ||
id = "com.hmh.hamyeonham.feature" | ||
implementationClass = "com.hmh.hamyeonham.plugin.AndroidFeaturePlugin" | ||
} | ||
create("android-kotlin") { | ||
id = "com.hmh.hamyeonham.kotlin" | ||
implementationClass = "com.hmh.hamyeonham.plugin.AndroidKotlinPlugin" | ||
} | ||
create("android-hilt") { | ||
id = "com.hmh.hamyeonham.hilt" | ||
implementationClass = "com.hmh.hamyeonham.plugin.AndroidHiltPlugin" | ||
} | ||
create("kotlin-serialization") { | ||
id = "com.hmh.hamyeonham.serialization" | ||
implementationClass = "com.hmh.hamyeonham.plugin.KotlinSerializationPlugin" | ||
} | ||
create("junit5") { | ||
id = "com.hmh.hamyeonham.junit5" | ||
implementationClass = "com.hmh.hamyeonham.plugin.JUnit5Plugin" | ||
} | ||
create("android-test") { | ||
id = "com.hmh.hamyeonham.test" | ||
implementationClass = "com.hmh.hamyeonham.plugin.AndroidTestPlugin" | ||
} | ||
create("compose") { | ||
id = "com.hmh.hamyeonham.compose" | ||
implementationClass = "com.hmh.hamyeonham.plugin.ComposePlugin" | ||
} | ||
} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
build-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/AndroidApplicationPlugin.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,11 @@ | ||
package com.hmh.hamyeonham.plugin | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class AndroidApplicationPlugin: Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
plugins.apply("com.android.application") | ||
configureAndroidCommonPlugin() | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
build-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/AndroidHiltPlugin.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,24 @@ | ||
package com.hmh.hamyeonham.plugin | ||
|
||
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 AndroidHiltPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
with(plugins) { | ||
apply("com.google.devtools.ksp") | ||
apply("com.google.dagger.hilt.android") | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
dependencies { | ||
"implementation"(libs.findLibrary("hilt").get()) | ||
"ksp"(libs.findLibrary("hilt.compiler").get()) | ||
"testImplementation"(libs.findLibrary("hilt.testing").get()) | ||
"kspTest"(libs.findLibrary("hilt.testing.compiler").get()) | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
build-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/AndroidKotlinPlugin.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,47 @@ | ||
package com.hmh.hamyeonham.plugin | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.api.plugins.ExtensionAware | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions | ||
|
||
class AndroidKotlinPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
with(plugins) { | ||
apply("kotlin-android") | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
extensions.getByType<BaseExtension>().apply { | ||
setCompileSdkVersion(libs.findVersion("compileSdk").get().requiredVersion.toInt()) | ||
|
||
defaultConfig { | ||
minSdk = libs.findVersion("minSdk").get().requiredVersion.toInt() | ||
targetSdk = libs.findVersion("targetSdk").get().requiredVersion.toInt() | ||
} | ||
|
||
compileOptions { | ||
isCoreLibraryDesugaringEnabled = true | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
(this as ExtensionAware).configure<KotlinJvmOptions> { | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
dependencies { | ||
"coreLibraryDesugaring"(libs.findLibrary("desugarLibs").get()) | ||
"implementation"(libs.findLibrary("kotlin").get()) | ||
"implementation"(libs.findLibrary("kotlin.coroutines").get()) | ||
"implementation"(libs.findLibrary("kotlin.datetime").get()) | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
build-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/AndroidTestPlugin.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,40 @@ | ||
package com.hmh.hamyeonham.plugin | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class AndroidTestPlugin: Plugin<Project> { | ||
override fun apply(target: Project): Unit = with(target) { | ||
apply<JUnit5Plugin>() | ||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
extensions.getByType<BaseExtension>().apply { | ||
defaultConfig { | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
testInstrumentationRunnerArguments["runnerBuilder"] = "de.mannodermaus.junit5.AndroidJUnit5Builder" | ||
} | ||
|
||
testOptions { | ||
unitTests { | ||
isIncludeAndroidResources = true | ||
} | ||
} | ||
|
||
packagingOptions { | ||
resources.excludes.add("META-INF/LICENSE*") | ||
} | ||
} | ||
|
||
dependencies { | ||
"testImplementation"(libs.findLibrary("junit").get()) | ||
"debugImplementation"(libs.findLibrary("truth").get()) | ||
"testImplementation"(libs.findLibrary("robolectric").get()) | ||
"androidTestImplementation"(libs.findBundle("androidx.android.test").get()) | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
build-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/CommonConfigs.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,39 @@ | ||
package com.hmh.hamyeonham.plugin | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
import java.util.Properties | ||
|
||
internal fun Project.configureAndroidCommonPlugin() { | ||
val properties = Properties().apply { | ||
load(rootProject.file("local.properties").inputStream()) | ||
} | ||
|
||
apply<AndroidKotlinPlugin>() | ||
apply<KotlinSerializationPlugin>() | ||
with(plugins) { | ||
apply("kotlin-parcelize") | ||
} | ||
apply<AndroidHiltPlugin>() | ||
|
||
extensions.getByType<BaseExtension>().apply { | ||
defaultConfig {} | ||
buildFeatures.apply { | ||
viewBinding = true | ||
buildConfig = true | ||
} | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
dependencies { | ||
"implementation"(libs.findLibrary("core.ktx").get()) | ||
"implementation"(libs.findLibrary("appcompat").get()) | ||
"implementation"(libs.findBundle("lifecycle").get()) | ||
"implementation"(libs.findLibrary("material").get()) | ||
"implementation"(libs.findLibrary("timber").get()) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
build-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/ComposePlugin.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,27 @@ | ||
package com.hmh.hamyeonham.plugin | ||
|
||
import com.android.build.gradle.BaseExtension | ||
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 ComposePlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
extensions.getByType<BaseExtension>().apply { | ||
buildFeatures.apply { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = libs.findVersion("compose.compiler").get().requiredVersion | ||
} | ||
} | ||
|
||
dependencies { | ||
"implementation"(platform(libs.findLibrary("compose.bom").get())) | ||
"implementation"(libs.findBundle("compose").get()) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
build-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/JUnit5Plugin.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,24 @@ | ||
package com.hmh.hamyeonham.plugin | ||
|
||
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 JUnit5Plugin : Plugin<Project> { | ||
override fun apply(target: Project): Unit = with(target) { | ||
with(plugins) { | ||
apply("de.mannodermaus.android-junit5") | ||
} | ||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
dependencies { | ||
"testImplementation"(libs.findBundle("junit5").get()) | ||
"androidTestImplementation"(libs.findLibrary("junit5").get()) | ||
"androidTestImplementation"(libs.findLibrary("junit5.params").get()) | ||
"androidTestImplementation"(libs.findLibrary("junit5.android.test.core").get()) | ||
"androidTestRuntimeOnly"(libs.findLibrary("junit5.android.test.runner").get()) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...d-logic/convention/src/main/kotlin/com/hmh/hamyeonham/plugin/KotlinSerializationPlugin.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 com.hmh.hamyeonham.plugin | ||
|
||
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 KotlinSerializationPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
with(plugins) { | ||
apply("org.jetbrains.kotlin.plugin.serialization") | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
dependencies { | ||
"implementation"(libs.findLibrary("kotlin.serialization.json").get()) | ||
} | ||
} | ||
} |
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,4 @@ | ||
# Gradle properties are not passed to included builds https://github.com/gradle/gradle/issues/2534 | ||
org.gradle.parallel=true | ||
org.gradle.caching=true | ||
org.gradle.configureondemand=true |
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,6 @@ | ||
#Fri Jan 13 12:46:38 KST 2023 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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,15 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic" | ||
include(":convention") | ||
|
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,6 +1,33 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
classpath(libs.kotlin.gradleplugin) | ||
classpath(libs.hilt.plugin) | ||
classpath(libs.agp) | ||
classpath(libs.ktlint) | ||
classpath(libs.oss.plugin) | ||
} | ||
} | ||
|
||
plugins { | ||
id("com.android.application") version "8.2.0" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false | ||
id("com.android.library") version "8.2.0" apply false | ||
alias(libs.plugins.android.application) apply false | ||
alias(libs.plugins.android.library) apply false | ||
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.dagger.hilt) apply false | ||
alias(libs.plugins.ktlint) apply false | ||
alias(libs.plugins.ksp) apply false | ||
alias(libs.plugins.kotlinx.serialization) apply false | ||
alias(libs.plugins.junit5) apply false | ||
alias(libs.plugins.google.services) apply false | ||
alias(libs.plugins.app.distribution) apply false | ||
alias(libs.plugins.crashlytics) apply false | ||
} | ||
|
||
tasks.register("clean", Delete::class) { | ||
delete(rootProject.layout.buildDirectory) | ||
} |
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,8 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} |
Oops, something went wrong.