Recently I started a new AEM as a Cloud Service project. The first thing I did was generate a new repository using the Maven archetype. I assumed it would be using Java 11 from the get-go. I came to learn it did not! Here are 3 things you'll need to get your AEMaaCS project ready for Java 11.
Update the Project to Use Java 11
As soon as I started to write Java code IntelliJ began screaming at my var. I love the var keyword in Java. The type inference speeds things up a lot. We need to update the root POM file. Set the Java version to 11 on the maven-enforcer-plugin and maven-compiler-plugin plugins.
Maven must be executed with a Java 11 JRE or higher.
Your IDE should pick up on the POM changes and switch the project to Java 11. That was easy! On to the next step.
Make Sure Maven Is Using Java 11
Once I was done making my changes I opened up a terminal and tried to run mvn clean install -P autoInstallSinglePlackage to get everything deployed. The enforcer I had configured denied me. I ran mvn --version and sure enough, Maven was using Java 8.