Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding recursive onLoad execution #3544

Open
jvican opened this issue Sep 15, 2017 · 0 comments
Open

Avoiding recursive onLoad execution #3544

jvican opened this issue Sep 15, 2017 · 0 comments
Labels
Enhancement uncategorized Used for Waffle integration

Comments

@jvican
Copy link
Member

jvican commented Sep 15, 2017

problem

You want to customize onLoad. But you need to get information about the current project, therefore using Project.extract(state).

The first time you reload your build, you'll find out that your build load doesn't end because it's stuck in a recursive load. This happens because Project.extract invokes the load hooks recursively, never ending the recursion.

There is precedent of people being confused by this: https://stackoverflow.com/questions/27760279/how-can-i-apply-setting-changes-on-onload-hook-in-sbt.

The solution to it is to define your own attribute and add/remove it appropriately.

An example on how to do this can be found in this build. The previous StackOverflow thread also shows how to do it.

expectation

Sbt handle this use case gracefully, without requiring me to short-circuit the recursion manually.

onLoad is becoming popular, and most of the times that users want to modify the state they want to get information from Extracted. I expect people to hit this problem often.

sbt version: all sbt versions

@eed3si9n eed3si9n added the uncategorized Used for Waffle integration label Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement uncategorized Used for Waffle integration
Projects
None yet
Development

No branches or pull requests

3 participants