-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Project evaluation in ProjectBuilder context throws "The settings are not yet available" since 7.3 #20301
Comments
Can confirm this as a regression introduced in |
i have a very similar issue:
when I call |
any updates on this bug since? |
Also reproducible with Gradle 7.6 |
Are there any known workarounds? |
This workaround works for me: (project as DefaultProject).evaluate()
val locationMock: ResourceLocation = mock {
on { file } doReturn File(".")
}
val resourcesMock: TextResource = mock {
on { location } doReturn locationMock
}
val settingsScriptMock: ScriptSource = mock {
on { resource } doReturn resourcesMock
}
project.gradle.settings = mock {
on { settingsScript } doReturn settingsScriptMock
}
val extension = project.extensions.getByName("android") as TestedAndroidConfig |
Haha... the point of using |
Yeah, but (project as DefaultProject).gradle.settings = object : SettingsInternal {
override fun getSettingsScript(): ScriptSource {
//
}
// other methods
} |
Can someone check if this is still broken on Gradle 8.1? I think it's fixed! |
Seems to still be broken in 8.1. |
Yes, still an issue for me with 8.1.1 |
Still there in |
It works for me in Gradle 8.0.2, so I don't have to apply this workaround. |
We worked it around by calling the problematic method in |
Hello, I currently tested with 8.4 ..... still occurs |
Expected Behavior
When calling
evaluate()
on a project created using the ProjectBuilder, theafterEvaluate {}
closures used to be evaluated to test specific parts of the project. Example:Current Behavior
In 7.2 running the above code runs with no issues, but since 7.3 up till the current latest of 7.4.1, an IlligalStateExeption is thrown with the message: "The settings are not yet available for build 'test'". The stack trace points to the
project.tasks
line. Stacktrace:Context
This breaks part of our current set of unittests for our internal gradle plugins. We use the ProjectBuilder whenever possible for test performance and better unit-isolation.
Steps to Reproduce
The following project has 2 tests explaining our use-cases and in both, the Exception is thrown as described above:
https://github.com/meonlol/demo-projectbuilder-settings-bug/blob/main/src/test/kotlin/com/bug/example/MyExampleTest.kt
Your Environment
Build scan URL: https://gradle.com/s/7kph6lfrph3ae
The text was updated successfully, but these errors were encountered: