Using JDK21 Preview Features And/Or Incubator Classes

Sometimes you want to play around with those new fancy features of JDK21 (or even newer
JDK's) like preview features and maybe some classes from the incubator.

So how can you configure your Maven build to support such a play lesson? It's easier than you
think. Let's start the configuration. My assumption is that you would like to play around
with preview features of JDK21 for example String Templates (JEP430). I just selected this JEP for demonstration. You can select whatever JEP is in the preview.

The first thing is to know that you have to activate the preview features via:

XML
 
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <enablePreview>true</enablePreview>
  </configuration>
</plugin>


CategoriesUncategorized