Skip to content

Missing annotation error - improved message #32218

@wfijolek

Description

@wfijolek

Expected Behavior

Previously discussed with @big-guy & @lptr on Slack, 21/01/2025

When user forgets to annotate a field in the task, they will see warning message similar to this:

Type 'Build_gradle.MyTask' property 'myProperty' is missing an input or output annotation.

    Reason: A property without annotation isn't considered during up-to-date checking.

    Possible solutions:
      1. Add an input or output annotation.
      2. Mark it as @Internal.

It could be improved, based on the type of that field.

  • For File-like properties (File, FileCollection, DirectoryProperty, etc), we suggest File-like annotations (@InputFile, @OutputFile, @Classpath, etc).
  • For primitive properties (String, Boolean, Provider where T is primitive), suggest @Input
  • For everything else suggest @Nested
  • Or @Internal to ignore.

Current Behavior (optional)

No response

Context

In AGP API we expose tools like: https://developer.android.com/reference/tools/gradle-api/8.3/com/android/build/api/variant/Aidl
where @Nested is required. Should the user forget to add it – they will receive a message that doesn't mention this particular annotation as being the possible solution. This change could help users discover the right way quicker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:featureA new functionalityin:work-validationtask validation, warnings, disable optimizationsin:writing-taskstask optionre:comprehensibilityreasonable errors and warnings, clear dsl, mental overload

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions