Hey folks, I'm trying to figure out how to dynamic...
# community-support
a
Hey folks, I'm trying to figure out how to dynamically configure a gradle build to fail if there are gradle deprecations (WarningMode.FAIL) I was thinking I could maybe do something like this in my settings.gradle file getGradle().getStartParameter().setWarningMode(WarningMode.FAIL) but it doesn't seem to do the trick. Any suggestions?
yeah I'm way off track here so far
was thinking that I could do something like: settings.apply { settings.startParameter.newInstance().warningMode = WarningMode.FAIL } or settings.apply { settings.startParameter.newBuild().warningMode = WarningMode.FAIL } and that this would result in a gradle project that applies a settings plugin containing the above and has deprecations in gradle scripts that it would result in the build failing...but don't seem to be able to get this to work as I expected it would
v
There are various settings that just cannot set dynamically from within the build, as the state is read before any user code is called. It seems this setting is one of those. If not, then how you try to set is totally wrong, because you create new settings objects where you set it which of course does not influence anything. The correct way would be simply
startParameter.warningMode = WarningMode.Fail
but as I said, this does not work either because it most probably is too late. So if you need to dynamically determine this flag, you either have to use a custom distribution where you change the Gradle code to contain your logic, or do it for example in the wrapper script if it is enough when it is from calling Gradle from the commandline
1
a
thanks Vampire! You never disappoint 🙂
👌 1