Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
.externalNativeBuild
.cxx
firebase-debug.log
.worktrees/
8 changes: 0 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,3 @@ android.useAndroidX=true
android.enableJetifier=false
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

android.defaults.buildfeatures.aidl=false
android.defaults.buildfeatures.buildconfig=false
android.defaults.buildfeatures.dataBinding=false
android.defaults.buildfeatures.renderscript=false
android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false
android.defaults.buildfeatures.viewbinding=false
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ fun Project.androidLibraryConfig(block: LibraryExtension.() -> Unit): Unit = blo
fun Project.kotlinConfig(configure: Action<KotlinAndroidProjectExtension>): Unit =
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("kotlin", configure)

@Suppress("DEPRECATION")
fun LibraryExtension.kotlinOptions(configure: Action<org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions>): Unit =
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("kotlinOptions", configure)

val Project.libs: LibrariesForLibs
get() = the<LibrariesForLibs>()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import dev.androidbroadcast.vbpd.gradle.androidLibraryConfig
import dev.androidbroadcast.vbpd.gradle.kotlinConfig
import dev.androidbroadcast.vbpd.gradle.kotlinOptions
import dev.androidbroadcast.vbpd.gradle.libs

version = libs.versions.vbpd.get()
group = "dev.androidbroadcast.vbpd"

plugins.apply(libs.plugins.jetbrains.kotlin.android.get().pluginId)
plugins.apply(libs.plugins.android.library.get().pluginId)
plugins.apply("maven-publish")
plugins.apply(libs.plugins.vanniktechMavenPublish.get().pluginId)
Expand Down Expand Up @@ -42,11 +40,6 @@ androidLibraryConfig {
targetCompatibility = javaVersion
}

kotlinOptions {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Kotlin jvm target lost 🐞 Bug ✓ Correctness

The PR removes kotlinOptions { jvmTarget = ... } but does not replace it with Kotlin
compilerOptions JVM target configuration, so Kotlin bytecode target is no longer pinned to the
repo’s intended jvmTarget=17 while Java is compiled for 17. This can produce mixed classfile targets
and can fail builds under stricter Kotlin JVM target validation or when using JVM-17-only bytecode
features.
Agent Prompt
### Issue description
Kotlin `jvmTarget` is no longer configured after removing `kotlinOptions { jvmTarget = ... }`. `jvmToolchain(17)` only selects the JDK used for compilation; it does not guarantee Kotlin bytecode is emitted for JVM 17.

### Issue Context
- Version catalog defines `jvmTarget = 17`.
- Java compilation is configured for 17.
- Kotlin configuration currently only sets toolchain.

### Fix Focus Areas
- gradle/conventions-plugins/vbpd-library-base/src/main/kotlin/vbpdconfig.gradle.kts[37-53]
- sample/build.gradle.kts[1-23]
- gradle/conventions-plugins/vbpd-library-base/src/main/kotlin/dev/androidbroadcast/vbpd/gradle/BaseExtensions.kt[22-28]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

jvmToolchain(17) in Kotlin 1.7+ sets both the JDK toolchain AND the jvmTarget. Additionally, AGP 9's built-in Kotlin aligns the Kotlin target with compileOptions Java target. Both are configured to 17 — the Kotlin jvmTarget is not lost.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Question:

jvmToolchain(17) in Kotlin 1.7+ sets both the JDK toolchain AND the jvmTarget. Additionally, AGP 9's built-in Kotlin aligns the Kotlin target with compileOptions Java target. Both are configured to 17 — the Kotlin jvmTarget is not lost.

Answer:

You can mitigate this kind of Gradle/Kotlin false-positive by adding explicit guidance via extra_instructions so the model verifies the effective Kotlin bytecode target before flagging “jvmTarget lost”, and treats jvmToolchain(...) / AGP alignment as acceptable evidence when applicable.

Add this to your repo (wiki/local/global) .pr_agent.toml:

[pr_code_suggestions]
extra_instructions = """\
When reviewing Gradle/Kotlin configuration changes:
- Do NOT claim 'Kotlin jvmTarget is lost' just because `kotlinOptions { jvmTarget = ... }` was removed.
- First verify whether Kotlin bytecode target is still effectively pinned via `jvmToolchain(<version>)`, Kotlin `compilerOptions`, or Android/AGP alignment with `compileOptions`.
- If the effective target remains consistent with Java (e.g., 17), do not open a bug; at most ask a clarifying question and cite the exact build files/lines that prove mismatch.
- Only raise a correctness bug when you can point to concrete evidence of mixed targets (Java 17 vs Kotlin != 17) in the diff/config.
"""

If this issue is being raised by /review rather than /improve, add the same idea there too:

[pr_reviewer]
extra_instructions = """\
For Gradle/Kotlin JVM target topics, verify the effective Kotlin bytecode target (toolchain/compilerOptions/AGP alignment) before claiming mismatch. Only flag when the diff shows concrete evidence of Kotlin target != Java target.
"""

To help you iterate, you can run:
/improve --config.output_relevant_configurations=true
to confirm which settings are actually applied.

Relevant Sources:

jvmTarget = libs.versions.jvmTarget.get()
freeCompilerArgs += listOf("-module-name", libraryId)
}

testOptions {
unitTests {
isIncludeAndroidResources = true
Comment on lines 40 to 45
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The -module-name free compiler argument that was previously set in the kotlinOptions block has been dropped and not migrated. This argument set a custom Kotlin module name (e.g., dev.androidbroadcast.vbpd.core) for each published library module, which prevents Kotlin module name clashes when consumers depend on multiple modules from this library.

The equivalent should be added in the kotlinConfig block using compilerOptions, e.g., compilerOptions { freeCompilerArgs.addAll("-module-name", libraryId) }.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

AGP 9 automatically sets -module-name from the namespace property, which is already set to libraryId in this convention plugin (line 19). Verified: compilation produces no warnings, and the module names match the previous values. Adding it manually caused a "passed multiple times" warning with AGP 9.

Expand Down
24 changes: 12 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[versions]
android-compileSdk = "35"
android-buildTools = "35.0.0"
android-minSdk = "21"
android-compileSdk = "36"
android-buildTools = "36.0.0"
android-minSdk = "23"
android-targetSdk = "35"
agp = "8.8.0"
androidx-activity = "1.10.0"
androidx-core = "1.15.0"
agp = "9.1.0"
androidx-activity = "1.12.4"
androidx-core = "1.17.0"
androidx-annotation = "1.9.1"
androidx-appcompat = "1.7.0"
androidx-fragment = "1.8.5"
androidx-appcompat = "1.7.1"
androidx-fragment = "1.8.9"
androidx-recyclerview = "1.4.0"
kotlin = "2.1.10"
kotlin = "2.3.10"
vanniktechMavenPublish = "0.30.0"
jvmTarget = "11"
jvmTarget = "17"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. jvmtarget set to 17 📘 Rule violation ✓ Correctness

The version catalog sets jvmTarget to 17, which violates the requirement to keep JVM
bytecode/targets at 11. This can cause modules to compile for Java 17, breaking consumers and
violating the mandated JVM level.
Agent Prompt
## Issue description
The PR configures `jvmTarget` as 17, but compliance requires Java/Kotlin bytecode target 11 across all JVM modules.

## Issue Context
`libs.versions.jvmTarget` is used by module build scripts (e.g., sample `compileOptions`) so changing it to 17 effectively makes the project compile for Java 17.

## Fix Focus Areas
- gradle/libs.versions.toml[15-15]
- sample/build.gradle.kts[19-22]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

AGP 9.x requires JVM 17+ — jvmTarget=11 is not compatible with AGP 9. This is not a rule violation, the old value was simply the previous project setting that needed to be updated along with the AGP major upgrade.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Question:

AGP 9.x requires JVM 17+ — jvmTarget=11 is not compatible with AGP 9. This is not a rule violation, the old value was simply the previous project setting that needed to be updated along with the AGP major upgrade.

Answer:

You can reduce/avoid this kind of “false violation” by adding a repository-specific constraint to the agent prompt so it won’t recommend (or insist on) downgrading JVM bytecode targets when AGP 9.x is in use.

Add an explicit instruction that:

  • AGP 9.x implies JDK/JVM target 17+ (so don’t flag “jvmTarget=17” as a violation)
  • Only flag JVM target mismatches if they contradict an explicitly stated project policy in-repo

Suggested config (TOML):

[pr_code_suggestions]
extra_instructions = """\
- This repo uses Android Gradle Plugin (AGP) 9.x; therefore Java/Kotlin toolchain and jvmTarget are expected to be 17+.
- Do NOT suggest changing jvmTarget back to 11 just to match historical settings.
- Only raise a “rule/policy violation” if an explicit, authoritative repo policy file (e.g., best_practices.md / compliance checklist / build conventions) states a different required target.
- If there is a conflict (e.g., consumers require 11), present it as a trade-off with options (multi-module targets, toolchains, publishing strategy), not as an unconditional violation.
"""

[pr_reviewer]
extra_instructions = """\
- Treat jvmTarget=17 as acceptable when AGP 9.x is present; avoid calling it a compliance violation unless an explicit repo policy mandates 11.
"""

If this feedback is coming from the /compliance tool (rather than /improve or /review), the most robust fix is to update your pr_compliance_checklist.yaml to reflect the AGP 9.x baseline (17+) instead of 11.

Relevant Sources:

vbpd = "2.0.4"
detekt = "1.23.8"
ktlint = "14.0.1"
kover = "0.9.7"
robolectric = "4.16.1"
mockk = "1.14.9"
androidx-test-core = "1.6.1"
androidx-test-runner = "1.6.2"
androidx-test-core = "1.7.0"
androidx-test-runner = "1.7.0"
junit = "4.13.2"

[libraries]
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 0 additions & 5 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.android.application)
alias(libs.plugins.parcelize)
}
Expand All @@ -22,10 +21,6 @@ android {
targetCompatibility = JavaVersion.toVersion(libs.versions.jvmTarget.get())
}

kotlinOptions {
jvmTarget = libs.versions.jvmTarget.get()
}

buildFeatures {
viewBinding = true
}
Expand Down
1 change: 1 addition & 0 deletions vbpd-core/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk=35
1 change: 1 addition & 0 deletions vbpd-reflection/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk=35
1 change: 1 addition & 0 deletions vbpd/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk=35
Loading