Description
Instead of using source and target the new parameter release (https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#release) should be used with Java 9+ as that also checks whether the used API is provided in the target Java release (https://docs.oracle.com/javase/9/tools/javac.htm#GUID-AEEC9F07-CB49-4E96-8BC7-BCC2C7F725C9__GUID-D343F6B4-3FDD-43A8-AD24-43DD70214471).
To be able to support both compilation with Java < 9 and above a profile should be used which either configures source and target or release.
You have to observe though that the parameter values are different though, as the former supports 1.6, 1.7 and 1.8 while the latter only supports 6, 7 and 8.