Skip to content

[2.x] fix: inputFileChanges with nested task scopes#8516

Merged
eed3si9n merged 11 commits intosbt:developfrom
MkDev11:fix/inputFileChanges-nested-task-scope-7489
Jan 14, 2026
Merged

[2.x] fix: inputFileChanges with nested task scopes#8516
eed3si9n merged 11 commits intosbt:developfrom
MkDev11:fix/inputFileChanges-nested-task-scope-7489

Conversation

@MkDev11
Copy link
Copy Markdown
Contributor

@MkDev11 MkDev11 commented Jan 13, 2026

Fix inputFileChanges with nested task scopes

Fixes #7489

The Problem

When you define a task scoped to another task and try to use inputFileChanges, it doesn't track file changes correctly:

otherTask / testTask / fileInputs := Seq(Glob(file("src"), **))

otherTask / testTask := {
  if ((otherTask / testTask).inputFileChanges.hasChanges) 
    println("CHANGED")
  else 
    println("NOT CHANGED")
}

Running otherTask / testTask always prints "NOT CHANGED", even after modifying files in src.

What was happening

The getTaskScope function was checking if the scope already had a task axis set. If it did, it would return that scope as-is. But with otherTask / testTask, the scope has otherTask in the task axis, while fileInputs is actually set at the testTask scope.

The Fix

Always use the key being queried (testTask) as the task axis, regardless of what's already in the scope. This ensures we look up fileInputs at the correct scope.


Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=94194147

Fixes sbt#7489

When using nested task scopes like otherTask / testTask, the
inputFileChanges macro was returning the wrong scope. It checked
if the scope already had a task axis and returned it as-is, but
this meant it would use otherTask's scope instead of testTask's.

The fix always sets the task axis to the key being queried,
ensuring fileInputs settings are found at the correct scope.
Adds a scripted test to verify that inputFileChanges works correctly
when using nested task scopes like otherTask / testTask.
The inputFileChanges macro doesn't work inside Def.uncached due to
macro expansion scope issues. Use Def.taskDyn pattern instead, which
is the same approach used in the file-hashes scripted test.
@MkDev11 MkDev11 marked this pull request as draft January 14, 2026 00:55
The inputFileChanges macro doesn't work with inline nested task scope
expressions like (otherTask / testTask).inputFiles. Using a val to hold
the scoped task key allows the macro to work properly.
@MkDev11 MkDev11 marked this pull request as ready for review January 14, 2026 01:05
@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented Jan 14, 2026

@eed3si9n all checks passed! could you please review the changes again and approve it?

Copy link
Copy Markdown
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.

Minor comment, but overall lgtm.

@eed3si9n eed3si9n changed the title fix: inputFileChanges with nested task scopes [2.x] fix: inputFileChanges with nested task scopes Jan 14, 2026
@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented Jan 14, 2026

@eed3si9n can you merge the PR?

@eed3si9n eed3si9n merged commit 82e370b into sbt:develop Jan 14, 2026
14 checks passed
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.

inputFileChanges cannot be scoped to a task scoped to another task

2 participants