Skip to content

Conversation

Duhemm
Copy link
Contributor

@Duhemm Duhemm commented Aug 11, 2025

Previously, sbt would fail to load build.sbt files when they included annotated definitions because the parser would not correctly recognize those definitions as such. In sbt 1.x, this used to be fine, because there was little use for annotations in build.sbt.

Starting with sbt 2, whether caching should be enabled for a task key can be controlled via annotations on the task key definition. Because these can appear in build.sbt, support for annotations in build.sbt becomes more important.

This patch enhances parsing of build.sbt by keeping the parsed trees around so that the AST can be used to determine whether a given line represents a setting or a definition, rather than relying on string matching.

Previously, sbt would fail to load build.sbt files when they included
annotated definitions because the parser would not correctly recognize
those definitions as such. In sbt 1.x, this used to be fine, because
there was little use for annotations in build.sbt.

Starting with sbt 2, whether caching should be enabled for a task key
can be controlled via annotations on the task key definition. Because
these can appear in build.sbt, support for annotations in build.sbt
becomes more important.

This patch enhances parsing of build.sbt by keeping the parsed trees
around so that the AST can be used to determine whether a given line
represents a setting or a definition, rather than relying on string
matching.
@Duhemm Duhemm requested a review from eed3si9n August 11, 2025 08:36
Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Nice!

@eed3si9n eed3si9n merged commit 16269ba into sbt:develop Aug 11, 2025
12 checks passed
@eed3si9n eed3si9n changed the title Support annotated definitions in build.sbt [2.x] fix: Support annotated definitions in build.sbt Aug 11, 2025
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.

2 participants