All Java processes launched should have default -Xmx values.
So, as your goal is to not start without -Xmx if I got you right, you should not need to do anything.
Other than that, you could use the org.gradle.jvmargs Gradle property to set the value for the Gradle daemon, but you need to set it also separately for started subprocesses on the according tasks.
Alternatively you could probably also use JAVA_TOOL_OPTIONS environment variable that is automatically considered by any Java process started and is handled by Java itself, totally independent of Gradle. But I don’t know how there the precedence is.