for gradle now one could do:
gradle clean build -x test -x javaDoc -PjavacRelease=17
for maven something like this works to build a different target binary:
mvn clean package -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dmaven.compiler.release=17