Skip to content

Fix KSP maven artifacts never being pinned or resolved#173

Open
minkuan88 wants to merge 2 commits intograb:masterfrom
minkuan88:fix-ksp-maven-pinning
Open

Fix KSP maven artifacts never being pinned or resolved#173
minkuan88 wants to merge 2 commits intograb:masterfrom
minkuan88:fix-ksp-maven-pinning

Conversation

@minkuan88
Copy link
Contributor

Problem

KSP processors declared via ksp(...) in Gradle were computed correctly into
WorkspaceDependencies but never made it through the pinning, dependency
resolution, or Bazel rule generation steps. This caused three silent failures:

Bug 1 — ArtifactPinner skipped ksp_maven entirely

shouldRunPinning() and pinArtifacts() only iterated over variantDeps, so
ksp_maven was never checked for staleness and ksp_maven_pin.sh was never
generated.

Bug 2 — DependencyResolutionService missing KSP from maven store

populateMavenStore() only iterated variantDeps, so getMavenDependency()
could not resolve KSP artifacts during Bazel script generation, leading to
unresolvable target references.

Bug 3 — Dangling Bazel target references from dropped KSP processors

RootBazelFileBuilder silently skipped processors with no
SymbolProcessorProvider service entry, but collectKspPluginDeps still
emitted Bazel target references for them, producing targets that don't exist
in the root BUILD.bazel.

Solution

Introduce aggregatedRepos in WorkspaceDependencies — a map of repo-name to
dependency list for artifacts that bypass the per-variant reduction pipeline
(e.g. ksp_maven). This sits alongside the existing variantDeps and is
propagated through all consumers.

Key changes:

  • WorkspaceDependencies: Added aggregatedRepos: Map<String, List<ResolvedDependency>>; renamed resultvariantDeps (with
    @SerialName("result") to preserve JSON backward compatibility); removed
    kspResult
  • ComputeWorkspaceDependencies: Writes KSP deps into
    aggregatedRepos["ksp_maven"] sorted and deduplicated by max version
  • ArtifactPinner: Updated shouldRunPinning() and pinArtifacts() to
    iterate both variantDeps and aggregatedRepos
  • DependencyResolutionService: Updated populateMavenStore() to also
    populate from aggregatedRepos; added getValidKspProcessorShortIds() which
    returns only processors that have a valid SymbolProcessorProvider service
    entry
  • RootBazelFileBuilder: Warns and skips processors with no
    processorClass instead of silently dropping them
  • DefaultDependenciesDataSource.collectKspPluginDeps(): Filters KSP
    plugin deps against getValidKspProcessorShortIds() so only processors with
    a generated kt_ksp_plugin target are referenced

ksp_maven was being computed and stored in WorkspaceDependencies but never
reaching the pinning, dependency resolution, or Bazel rule generation steps
due to three bugs:

Bug 1 - ArtifactPinner skipped ksp_maven entirely: shouldRunPinning() and
pinArtifacts() only iterated over variantDeps, so ksp_maven was never checked
for staleness and ksp_maven_pin.sh was never generated.

Bug 2 - DependencyResolutionService missing KSP from maven store:
populateMavenStore() only iterated variantDeps, so getMavenDependency() would
fail to resolve KSP artifacts during Bazel script generation.

Bug 3 - Dangling Bazel target references from dropped KSP processors:
RootBazelFileBuilder silently dropped processors with no SymbolProcessorProvider
service entry while collectKspPluginDeps still referenced them, producing
unresolvable Bazel targets.

To fix these, introduce aggregatedRepos in WorkspaceDependencies to hold
repo-keyed dependencies (e.g. ksp_maven) that bypass the variant reduction
pipeline, alongside the existing variantDeps (renamed from result, with
@SerialName to preserve JSON backward compatibility). All consumers are updated
to handle both maps accordingly.
@minkuan88 minkuan88 force-pushed the fix-ksp-maven-pinning branch from 325ddc7 to 2c726ff Compare March 6, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant