google / google/ksp

Emit warning when `Dependencies` has zero files and `aggregating = false`

Open
#3,100 0 comments 0 reactions 0 assignees View on GitHub
enhancement P4
Dominant language
Kotlin
Stars
3.5k
Forks
415
Avg merge
1d 2h
Merged PRs (30d)
53

Description

> Ok^^, well i don't want to speculate too much about hypothetical use-cases. We do use signatures that are input for the generator, so in our case we should specify those classes as dependencies.
>
> If empty dependencies with aggregate=false is not a valid KSP configuration, getting a warning would be good i guess, maybe even a hard error in future releases.

_Originally posted by @Jan-Thes in [#2854](https://github.com/google/ksp/issues/2854#issuecomment-5120910285)_

It's a helpful to emit a warning when `Dependencies` contains zero files and has `aggregating = false`. This means that the generated file depends **only** on the empty set of output files. However, if that is really the case, then it might as well just be a source file in project instead of being generated. The reasoning in terms of incremental compilation is as follows:
- Either the generated output file should be regenerated when any file changes, in which case it should be configured with `aggregating = true`.
- Or it should only be generated once and included in all builds.
- Assume that the file really does not depend on the codebase. In this case, generating it is a one-time procedure and it can be included in the project as is.
- Assume that the generated output file does in fact depend on at least one source file in the project. In this case, it should reference that same source file in the `Dependencies` object. However, that contradicts that it has no dependencies, i.e., that the list is of length zero (it is strictly greater).

Contributor guide

Open the contributing guide

Research direction

Start by locating the KSP API implementation that constructs or validates Dependencies, focusing on the zero-file and aggregating=false combination described here. Check the existing warning tests or validation tests around Dependencies, then add coverage showing that this configuration emits a warning without changing other dependency cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.