Fix KSP maven artifacts never being pinned or resolved#173
Open
minkuan88 wants to merge 2 commits intograb:masterfrom
Open
Fix KSP maven artifacts never being pinned or resolved#173minkuan88 wants to merge 2 commits intograb:masterfrom
minkuan88 wants to merge 2 commits intograb:masterfrom
Conversation
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.
Fixes merge conflicts
325ddc7 to
2c726ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
KSP processors declared via
ksp(...)in Gradle were computed correctly intoWorkspaceDependenciesbut never made it through the pinning, dependencyresolution, or Bazel rule generation steps. This caused three silent failures:
Bug 1 —
ArtifactPinnerskippedksp_mavenentirelyshouldRunPinning()andpinArtifacts()only iterated overvariantDeps, soksp_mavenwas never checked for staleness andksp_maven_pin.shwas nevergenerated.
Bug 2 —
DependencyResolutionServicemissing KSP from maven storepopulateMavenStore()only iteratedvariantDeps, sogetMavenDependency()could not resolve KSP artifacts during Bazel script generation, leading to
unresolvable target references.
Bug 3 — Dangling Bazel target references from dropped KSP processors
RootBazelFileBuildersilently skipped processors with noSymbolProcessorProviderservice entry, butcollectKspPluginDepsstillemitted Bazel target references for them, producing targets that don't exist
in the root
BUILD.bazel.Solution
Introduce
aggregatedReposinWorkspaceDependencies— a map of repo-name todependency list for artifacts that bypass the per-variant reduction pipeline
(e.g.
ksp_maven). This sits alongside the existingvariantDepsand ispropagated through all consumers.
Key changes:
WorkspaceDependencies: AddedaggregatedRepos: Map<String, List<ResolvedDependency>>; renamedresult→variantDeps(with@SerialName("result")to preserve JSON backward compatibility); removedkspResultComputeWorkspaceDependencies: Writes KSP deps intoaggregatedRepos["ksp_maven"]sorted and deduplicated by max versionArtifactPinner: UpdatedshouldRunPinning()andpinArtifacts()toiterate both
variantDepsandaggregatedReposDependencyResolutionService: UpdatedpopulateMavenStore()to alsopopulate from
aggregatedRepos; addedgetValidKspProcessorShortIds()whichreturns only processors that have a valid
SymbolProcessorProviderserviceentry
RootBazelFileBuilder: Warns and skips processors with noprocessorClassinstead of silently dropping themDefaultDependenciesDataSource.collectKspPluginDeps(): Filters KSPplugin deps against
getValidKspProcessorShortIds()so only processors witha generated
kt_ksp_plugintarget are referenced