Skip to content

Commit

Permalink
Merge pull request #302 from BCSDLab/feature/gradle-cleanup
Browse files Browse the repository at this point in the history
Migration Groovy to Kotlin DSL
  • Loading branch information
Jokwanhee authored Jul 8, 2024
2 parents 87e928f + 560980c commit af8f16e
Show file tree
Hide file tree
Showing 23 changed files with 409 additions and 372 deletions.
12 changes: 12 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ gradlePlugin {
id = "in.koreatech.plugin.orbit"
implementationClass = "AndroidApplicationOrbitConventionPlugin"
}
register("AndroidLibraryPlugin") {
id = "in.koreatech.plugin.library"
implementationClass = "AndroidLibraryConventionPlugin"
}
register("FirebasePlugin") {
id = "in.koreatech.plugin.firebase"
implementationClass = "FirebaseConventionPlugin"
}
register("JavaLibraryPlugin") {
id = "in.koreatech.plugin.java"
implementationClass = "JavaLibraryConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import com.android.build.api.dsl.ApplicationExtension
import `in`.koreatech.convention.configureAndroidHilt
import `in`.koreatech.convention.implementation
import `in`.koreatech.convention.kapt
import `in`.koreatech.convention.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

internal class AndroidApplicationHiltConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.google.dagger.hilt.android")
}
extensions.configure<ApplicationExtension> {
configureAndroidHilt(this)
dependencies {
implementation(libs.findBundle("hilt").get())
kapt(libs.findLibrary("hilt-compiler").get())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.LibraryExtension
import `in`.koreatech.convention.configureAndroidLibrary
import `in`.koreatech.convention.configureAndroidTest
import `in`.koreatech.convention.configureTest
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

internal class AndroidLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.kapt")
apply("org.jetbrains.kotlin.android")
}
extensions.configure<LibraryExtension> {
configureAndroidLibrary(this)
configureTest()
configureAndroidTest()
}
}
}

}
22 changes: 22 additions & 0 deletions build-logic/convention/src/main/java/FirebaseConventionPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import `in`.koreatech.convention.implementation
import `in`.koreatech.convention.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.extra

internal class FirebaseConventionPlugin: Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.google.firebase.crashlytics")
apply("com.google.firebase.appdistribution")
}
dependencies {
implementation(platform(libs.findLibrary("firebase-bom").get()))
implementation(libs.findBundle("firebase").get())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import `in`.koreatech.convention.configureKotlinJvm
import `in`.koreatech.convention.implementation
import `in`.koreatech.convention.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

class JavaLibraryConventionPlugin: Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("java-library")
}
dependencies {
implementation(libs.findLibrary("javax-inject").get())
}
configureKotlinJvm()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package `in`.koreatech.convention

import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project

internal fun Project.configureAndroidLibrary(
commonExtension: CommonExtension<*, *, *, *>,
) {
(commonExtension as? LibraryExtension)?.let {
it.defaultConfig.targetSdk = 34
}

commonExtension.apply {
(this as? LibraryExtension)?.let {
it.defaultConfig.targetSdk = 34
}

compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

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

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}

packagingOptions {
resources.excludes += "DebugProbesKt.bin"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal fun configureAndroidProject(
it.defaultConfig.targetSdk = 34
}
defaultConfig {
minSdk = 23
minSdk = 24
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package `in`.koreatech.convention

import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension

internal fun Project.configureKotlinJvm() {
extensions.configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
25 changes: 10 additions & 15 deletions build.gradle → build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
mavenCentral()
}

ext {
/* Common */
compileSdkVersion = 34
minSdkVersion = 21
targetSdkVersion = 34
versionName = "3.4.3"
minVersionCode = 30403
extra.apply {
set("versionName", "3.4.3")
set("versionCode", 30403)
}

dependencies {
classpath libs.android.gradle.tool
classpath libs.kotlin.gradle
classpath libs.android.gradle.crashlytics
classpath libs.firebase.appdistribution.gradle
classpath libs.hilt.gradle.plugin
classpath(libs.android.gradle.tool)
classpath(libs.kotlin.gradle)
classpath(libs.android.gradle.crashlytics)
classpath(libs.firebase.appdistribution.gradle)
classpath(libs.hilt.gradle.plugin)
}
}

Expand All @@ -34,6 +29,6 @@ plugins {
alias(libs.plugins.androidLibrary) apply false
}

tasks.register('clean', Delete) {
delete rootProject.buildDir
tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}
118 changes: 0 additions & 118 deletions core/build.gradle

This file was deleted.

Loading

0 comments on commit af8f16e

Please sign in to comment.