gradle/gradle#1151 will be fixed in 9.7.0 RC1. Once we've upgraded to 9.7, we should be able to revert 9369986.