1

As part of the current Java enhancement development process adopted by the OpenJDK project, some new features under development for Java are offered in pre-release form as a preview API or as an incubating API.

For example:

If one wishes to try these new pre-release features using IntelliJ for a project driven by Maven or Gradle, what configuration to the project and/or IDE is needed?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • Is this is a Maven/gradle project - se the corresponding compiler options in Maven/Gradle build files. Otherwise there is Settings (Preferences on macOS) | Build, Execution, Deployment | Compiler | Java Compiler | Javac Options | **Additional command line parameters** you can pass. – Andrey Oct 06 '22 at 14:19
  • For Gradle, see [this Answer](https://stackoverflow.com/a/74311121/642706) on a duplicate Question. – Basil Bourque Nov 04 '22 at 02:10

1 Answers1

1

In maven for example, if you put

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <compilerArgs>--enable-preview</compilerArgs>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>--enable-preview</argLine>
            </configuration>
        </plugin>

The IDE will automatically detect the flag and will enable preview support. Incubator features need to be imported as modules.

I would suggest to use Maven, because Gradle always lags with introducing support for new Java versions.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Borislav Stoilov
  • 3,247
  • 2
  • 21
  • 46