Skip to content

Commit

Permalink
feat[custom-plugin]: custom build-logic plugin implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
SaifulSaif007 committed Nov 7, 2024
1 parent a745372 commit 96bde94
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 106 deletions.
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id(libs.plugins.com.android.app.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId)
Expand Down
18 changes: 2 additions & 16 deletions base_unit_test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id(libs.plugins.com.android.library.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId)
`build-logic`
}

android {
namespace = "com.saiful.test.unit"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
Expand All @@ -24,13 +16,7 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_19.toString()
}

}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id(libs.plugins.com.android.app.get().pluginId) apply false
id(libs.plugins.com.android.library.get().pluginId) apply false
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId) apply false
id(libs.plugins.hilt.plugin.get().pluginId) version "2.47" apply false
id(libs.plugins.hilt.plugin.get().pluginId) apply false
id(libs.plugins.org.jetbrains.kotlin.kapt.get().pluginId) apply false
id(libs.plugins.org.jetbrains.kotlin.jvm.get().pluginId) apply false
id(libs.plugins.gms.google.service.get().pluginId) version "4.4.1" apply false
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}

dependencies {
implementation(gradleApi())
implementation(libs.build.gradle)
implementation(libs.build.gradle.api)
implementation(libs.kotlin.gradle)
}
implementation(libs.android.gradlePlugin)
implementation(libs.kotlin.gradlePlugin)
implementation(libs.hilt.plugin)
}
30 changes: 29 additions & 1 deletion buildSrc/src/main/kotlin/build-logic.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
plugins {

id("com.android.library")
id("org.jetbrains.kotlin.android")
}

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

android {
compileSdk = 34

defaultConfig {
minSdk = 24
targetSdk = 33

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
vectorDrawables {
useSupportLibrary = true
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_19.toString()
}

}
15 changes: 2 additions & 13 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id(libs.plugins.com.android.library.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.kapt.get().pluginId)
`build-logic`
}

android {
namespace = "com.saiful.core"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")

val clientID: String by project
val apiKey = System.getenv("CLIENT_ID") ?: clientID
Expand All @@ -32,13 +27,7 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_19.toString()
}

buildFeatures {
buildConfig = true
}
Expand Down
20 changes: 3 additions & 17 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id(libs.plugins.com.android.library.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId)
alias(libs.plugins.hilt.plugin)
id(libs.plugins.hilt.plugin.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.kapt.get().pluginId)
`build-logic`
}

android {
namespace = "com.saiful.data"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
Expand All @@ -26,13 +18,7 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_19.toString()
}

testOptions {
unitTests.isReturnDefaultValues = true
}
Expand Down
20 changes: 3 additions & 17 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id(libs.plugins.com.android.library.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId)
alias(libs.plugins.hilt.plugin)
id(libs.plugins.hilt.plugin.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.kapt.get().pluginId)
`build-logic`
}

android {
namespace = "com.saiful.domain"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
Expand All @@ -26,13 +18,7 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_19.toString()
}

testOptions {
unitTests.isReturnDefaultValues = true
}
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashly
mock-webserver = { group = "com.squareup.okhttp3", name = "mockwebserver", version.ref = "mock-webserver" }
logging-interceptor = {group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "logging-interceptor"}

build-gradle = {group = "com.android.tools.build", name ="gradle", version.ref = "agp"}
build-gradle-api = {group = "com.android.tools.build", name = "gradle-api", version.ref = "agp"}
kotlin-gradle = {group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-bom"}
# Dependencies of the included build-logic
android-gradlePlugin = {group = "com.android.tools.build", name ="gradle", version.ref = "agp"}
kotlin-gradlePlugin = {group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-bom"}

#Test
junit = { group = "junit", name = "junit", version.ref = "junit" }
Expand Down
16 changes: 1 addition & 15 deletions mock/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ plugins {
id(libs.plugins.com.android.library.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.kapt.get().pluginId)
`build-logic`
}

android {
namespace = "com.saiful.mock"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
Expand All @@ -24,13 +17,6 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
Expand Down
19 changes: 2 additions & 17 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id(libs.plugins.com.android.library.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.android.get().pluginId)
alias(libs.plugins.hilt.plugin)
id(libs.plugins.hilt.plugin.get().pluginId)
id(libs.plugins.org.jetbrains.kotlin.kapt.get().pluginId)
`build-logic`
}

android {
namespace = "com.saiful.presentation"
compileSdk = 34

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
Expand All @@ -27,13 +19,6 @@ android {
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_19.toString()
}
buildFeatures {
compose = true
}
Expand Down

0 comments on commit 96bde94

Please sign in to comment.