Skip to content
Draft
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
22 changes: 15 additions & 7 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
import org.gradle.kotlin.dsl.javaToolchains
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
`kotlin-dsl`
}


group = "org.convention.buildlogic"

// Configure the build-logic plugins to target JDK 19
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update outdated comment.

The comment references JDK 19, but the code now configures Java 17. Update the comment to match the actual configuration.

📝 Proposed fix
-// Configure the build-logic plugins to target JDK 19
+// Configure the build-logic plugins to target JDK 17
 // This matches the JDK used to build the project, and is not related to what is running on device.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Configure the build-logic plugins to target JDK 19
// Configure the build-logic plugins to target JDK 17
// This matches the JDK used to build the project, and is not related to what is running on device.
🤖 Prompt for AI Agents
In @build-logic/convention/build.gradle.kts at line 11, Update the outdated
comment that reads "Configure the build-logic plugins to target JDK 19" so it
matches the actual configuration (JDK 17); locate the comment in
build.gradle.kts (the line containing that phrase) and change the text to
reference JDK 17 instead of JDK 19.

// This matches the JDK used to build the project, and is not related to what is running on device.
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
//java {
// sourceCompatibility = JavaVersion.VERSION_17
// targetCompatibility = JavaVersion.VERSION_17
//}

kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

//kotlin {
// compilerOptions {
// jvmTarget = JvmTarget.JVM_17
// }
//}

dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.android.tools.common)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AndroidLintConventionPlugin : Plugin<Project> {
pluginManager.hasPlugin("com.android.application") ->
configure<ApplicationExtension> { lint(Lint::configure) }

pluginManager.hasPlugin("com.android.library") ->
pluginManager.hasPlugin("com.android.kotlin.multiplatform.library") ->
configure<LibraryExtension> { lint(Lint::configure) }

else -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@

import com.android.build.gradle.LibraryExtension
import org.convention.configureFlavors
import org.convention.configureKotlinAndroid
import org.convention.configureKotlin
import org.convention.configureKotlinMultiplatform
import org.convention.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

/**
Expand All @@ -16,7 +12,7 @@ class KMPLibraryConventionPlugin: Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("com.android.kotlin.multiplatform.library")
apply("org.jetbrains.kotlin.multiplatform")
apply("org.convention.kmp.koin")
apply("org.convention.detekt.plugin")
Expand All @@ -25,20 +21,10 @@ class KMPLibraryConventionPlugin: Plugin<Project> {
apply("org.jetbrains.kotlin.plugin.parcelize")
}


configureKotlinMultiplatform()

extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 36
configureFlavors(this)
// The resource prefix is derived from the module name,
// so resources inside ":core:module1" must be prefixed with "core_module1_"
resourcePrefix = path
.split("""\W""".toRegex())
.drop(1).distinct()
.joinToString(separator = "_")
.lowercase() + "_"
}
configureKotlin()

dependencies {
add("commonMainImplementation", libs.findLibrary("kotlinx.serialization.json").get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ class KMPRoomConventionPlugin : Plugin<Project> {
}

dependencies {
// Adding ksp dependencies for multiple platforms
"implementation"(libs.findLibrary("androidx.room.ktx").get())
add("androidMainImplementation", libs.findLibrary("androidx.room.runtime").get())
add("androidMainImplementation", libs.findLibrary("androidx.sqlite.bundled").get())
add("desktopMainImplementation", libs.findLibrary("androidx.room.runtime").get())
add("desktopMainImplementation", libs.findLibrary("androidx.sqlite.bundled").get())
add("nativeMainImplementation", libs.findLibrary("androidx.room.runtime").get())
add("nativeMainImplementation", libs.findLibrary("androidx.sqlite.bundled").get())
add("nonJsCommonMainImplementation", libs.findLibrary("androidx.room.runtime").get())
add("nonJsCommonMainImplementation", libs.findLibrary("androidx.sqlite.bundled").get())

listOf(
"kspDesktop",
"kspAndroid",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal fun Project.configureKotlinJvm() {
/**
* Configure base Kotlin options
*/
private fun Project.configureKotlin() {
fun Project.configureKotlin() {
// Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.convention

import com.android.build.api.dsl.androidLibrary
import com.android.build.gradle.internal.ide.kmp.KotlinAndroidSourceSetMarker.Companion.android
Comment on lines +3 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid using internal Android Gradle Plugin APIs.

The import com.android.build.gradle.internal.ide.kmp.KotlinAndroidSourceSetMarker.Companion.android references an internal AGP class (internal package). Internal APIs are not part of the public contract and may change or be removed without notice in future AGP versions, causing build breakages.

Additionally, this import doesn't appear to be used in the current file.

Suggested fix
 import com.android.build.api.dsl.androidLibrary
-import com.android.build.gradle.internal.ide.kmp.KotlinAndroidSourceSetMarker.Companion.android
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import com.android.build.api.dsl.androidLibrary
import com.android.build.gradle.internal.ide.kmp.KotlinAndroidSourceSetMarker.Companion.android
import com.android.build.api.dsl.androidLibrary
🤖 Prompt for AI Agents
In @build-logic/convention/src/main/kotlin/org/convention/KotlinMultiplatform.kt
around lines 3 - 4, The file imports an internal AGP symbol
com.android.build.gradle.internal.ide.kmp.KotlinAndroidSourceSetMarker.Companion.android
which is unsafe and (per review) unused; remove that import and any references
to KotlinAndroidSourceSetMarker.android from KotlinMultiplatform.kt, and if you
need Android source-set wiring use the public DSL/API (e.g., androidLibrary or
the official Kotlin Multiplatform sourceSet accessors) instead of the internal
class; ensure the remaining imports (like androidLibrary) are kept only if
actually used.

import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension

/**
* Configure the Kotlin Multiplatform plugin with the default hierarchy template and additional targets.
Expand All @@ -17,8 +20,17 @@ internal fun Project.configureKotlinMultiplatform() {
extensions.configure<KotlinMultiplatformExtension> {
applyProjectHierarchyTemplate()

androidLibrary {
compileSdk = 36
minSdk = 26
androidResources.enable = true
enableCoreLibraryDesugaring = true
dependencies.apply {
add("coreLibraryDesugaring", libs.findLibrary("android.desugarJdkLibs").get())
}
}

jvm("desktop")
androidTarget()
iosSimulatorArm64()
iosX64()
iosArm64()
Expand Down
13 changes: 13 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,18 @@ dependencyResolutionManagement {
}
}

pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}

plugins {
id("org.jetbrains.kotlin.jvm") version "2.3.0"
}
}


rootProject.name = "build-logic"
include(":convention")
21 changes: 14 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
// google {
// content {
// includeGroupByRegex("com\\.android.*")
// includeGroupByRegex("com\\.google.*")
// includeGroupByRegex("androidx.*")
// }
// }
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {

classpath(libs.google.oss.licenses.plugin) {
exclude(group = "com.google.protobuf")
}
}

}

plugins {
alias(libs.plugins.kotlinCocoapods) apply false
alias(libs.plugins.codingfeline.buildKonfig) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.kotlin.multiplatform.library) apply false
alias(libs.plugins.android.test) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.serialization) apply false
Expand All @@ -47,6 +52,8 @@ plugins {
alias(libs.plugins.room) apply false
}



object DynamicVersion {
fun setDynamicVersion(file: File, version: String) {
val cleanedVersion = version.split('+')[0]
Expand Down
Loading