-
Notifications
You must be signed in to change notification settings - Fork 1
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
[REFACTOR/#171] buildSrc에서 build-logic 마이그레이션 #172
Changes from all commits
61d9a8f
4621224
6f46ed6
d3ad633
f89f045
fa958a2
205d670
36f3d80
da6f9f8
468161a
c5332e3
528ee50
44b55b6
111a42a
51111ae
c092532
3f0fbf9
e57c043
19b3bf8
d1f6fc8
be09c80
bb8d71f
fd8b074
1d237c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
dependencies { | ||
implementation(libs.android.gradlePlugin) | ||
implementation(libs.kotlin.gradlePlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("AndroidApplicationPlugin") { | ||
id = "kr.genti.androidApplication" | ||
implementationClass = "kr.genti.convention.plugin.AndroidApplicationPlugin" | ||
} | ||
register("AndroidLibraryPlugin") { | ||
id = "kr.genti.androidLibrary" | ||
implementationClass = "kr.genti.convention.plugin.AndroidLibraryPlugin" | ||
} | ||
register("JavaLibraryPlugin") { | ||
id = "kr.genti.javaLibrary" | ||
implementationClass = "kr.genti.convention.plugin.JavaLibraryPlugin" | ||
} | ||
|
||
register("KotlinPlugin") { | ||
id = "kr.genti.kotlin" | ||
implementationClass = "kr.genti.convention.plugin.KotlinPlugin" | ||
} | ||
register("HiltPlugin") { | ||
id = "kr.genti.hilt" | ||
implementationClass = "kr.genti.convention.plugin.HiltPlugin" | ||
} | ||
register("TestPlugin") { | ||
id = "kr.genti.test" | ||
implementationClass = "kr.genti.convention.plugin.TestPlugin" | ||
} | ||
register("versionPlugin") { | ||
id = "kr.genti.version" | ||
implementationClass = "kr.genti.convention.plugin.VersionPlugin" | ||
} | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 단순한 궁금증인데, 저는 모든 버전을 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. libs.version.toml에서는 implementation 관련된 버전만 관리하는게 편할 것 같아서 했습니다! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
package kr.genti.convention | ||
|
||
import org.gradle.api.JavaVersion | ||
|
||
object Constants { | ||
const val packageName = "kr.genti.android" | ||
|
||
const val compileSdk = 34 | ||
const val minSdk = 28 | ||
const val targetSdk = 34 | ||
|
||
const val versionCode = 18 | ||
const val versionName = "2.0.2" | ||
|
||
const val jvmVersion = "17" | ||
val JAVA_VERSION = JavaVersion.VERSION_17 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package kr.genti.convention.config | ||
|
||
import kr.genti.convention.extension.getLibrary | ||
import kr.genti.convention.extension.implementation | ||
import kr.genti.convention.plugin.HiltPlugin | ||
import kr.genti.convention.plugin.KotlinPlugin | ||
import kr.genti.convention.plugin.TestPlugin | ||
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 | ||
|
||
fun Project.configureAndroidCommonPlugin() { | ||
apply<KotlinPlugin>() | ||
apply<HiltPlugin>() | ||
apply<TestPlugin>() | ||
with(plugins) { | ||
apply("kotlin-parcelize") | ||
apply("org.jetbrains.kotlin.plugin.serialization") | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
dependencies { | ||
implementation(libs.getLibrary("material-design")) | ||
implementation(libs.getLibrary("timber")) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package kr.genti.convention.extension | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.plugins.ExtensionAware | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions | ||
|
||
fun CommonExtension<*, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { | ||
(this as ExtensionAware).extensions.configure("kotlinOptions", block) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package kr.genti.convention.extension | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.file.ConfigurableFileCollection | ||
import org.gradle.api.file.ConfigurableFileTree | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.kotlin.dsl.DependencyHandlerScope | ||
|
||
fun DependencyHandlerScope.implementation(project: Project) { | ||
"implementation"(project) | ||
} | ||
|
||
fun DependencyHandlerScope.implementation(provider: Provider<*>) { | ||
"implementation"(provider) | ||
} | ||
|
||
fun DependencyHandlerScope.implementation(fileTree: ConfigurableFileTree) { | ||
"implementation"(fileTree) | ||
} | ||
|
||
fun DependencyHandlerScope.implementation(fileCollection: ConfigurableFileCollection) { | ||
"implementation"(fileCollection) | ||
} | ||
|
||
fun DependencyHandlerScope.debugImplementation(provider: Provider<*>) { | ||
"debugImplementation"(provider) | ||
} | ||
|
||
fun DependencyHandlerScope.releaseImplementation(provider: Provider<*>) { | ||
"releaseImplementation"(provider) | ||
} | ||
|
||
fun DependencyHandlerScope.kapt(provider: Provider<*>) { | ||
"kapt"(provider) | ||
} | ||
|
||
fun DependencyHandlerScope.coreLibraryDesugaring(provider: Provider<*>) { | ||
"coreLibraryDesugaring"(provider) | ||
} | ||
|
||
fun DependencyHandlerScope.androidTestImplementation(provider: Provider<*>) { | ||
"androidTestImplementation"(provider) | ||
} | ||
|
||
fun DependencyHandlerScope.testImplementation(provider: Provider<*>) { | ||
"testImplementation"(provider) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package kr.genti.convention.extension | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
val Project.libs: VersionCatalog | ||
get() = extensions.getByType<VersionCatalogsExtension>().named("libs") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package kr.genti.convention.extension | ||
|
||
import org.gradle.api.artifacts.ExternalModuleDependencyBundle | ||
import org.gradle.api.artifacts.MinimalExternalModuleDependency | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.provider.Provider | ||
|
||
fun VersionCatalog.getBundle(bundleName: String): Provider<ExternalModuleDependencyBundle> = | ||
findBundle(bundleName).orElseThrow { | ||
NoSuchElementException("Bundle with name $bundleName not found in the catalog") | ||
} | ||
|
||
fun VersionCatalog.getLibrary(libraryName: String): Provider<MinimalExternalModuleDependency> = | ||
findLibrary(libraryName).orElseThrow { | ||
NoSuchElementException("Library with name $libraryName not found in the catalog") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package kr.genti.convention.plugin | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import kr.genti.convention.Constants | ||
import kr.genti.convention.config.configureAndroidCommonPlugin | ||
import kr.genti.convention.extension.kotlinOptions | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
class AndroidApplicationPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.application") | ||
} | ||
|
||
extensions.configure<ApplicationExtension> { | ||
configureAndroidCommonPlugin() | ||
|
||
namespace = Constants.packageName | ||
compileSdk = Constants.compileSdk | ||
|
||
defaultConfig { | ||
applicationId = Constants.packageName | ||
targetSdk = Constants.targetSdk | ||
minSdk = Constants.minSdk | ||
versionCode = Constants.versionCode | ||
versionName = Constants.versionName | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = Constants.JAVA_VERSION | ||
targetCompatibility = Constants.JAVA_VERSION | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = Constants.jvmVersion | ||
} | ||
|
||
buildFeatures { | ||
buildConfig = true | ||
viewBinding = true | ||
dataBinding = true | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro", | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 매번 이렇게 하드코딩하는것이 휴먼 에러를 발생시킬 수 있다고 생각해서
libs.version.toml
의 플러그인으로 등록해두는 편입니다. 휴먼에러 방지용!!