From 82ff10cf95f6161fedab6dc5b2ce0aaf8544f92c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sun, 6 Mar 2022 19:35:42 +1000 Subject: [PATCH] add paremeter to configure javac feature --enable-preview (#199) Signed-off-by: Olivier Lamy --- .../plexus/compiler/CompilerConfiguration.java | 15 +++++++++++++++ .../plexus/compiler/javac/JavacCompiler.java | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java index 9edf10ea..86b2fa4b 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java @@ -178,6 +178,11 @@ public class CompilerConfiguration */ private String debugFileName; + /** + * configure --enable-preview of java compiler + */ + private boolean enablePreview; + // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- @@ -632,6 +637,16 @@ public void setParameters(boolean parameters) this.parameters = parameters; } + public boolean isEnablePreview() + { + return enablePreview; + } + + public void setEnablePreview(boolean enablePreview) + { + this.enablePreview = enablePreview; + } + public void setProc(String proc ) { this.proc = proc; diff --git a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java index 2a2263d9..4b3e5ae8 100644 --- a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java +++ b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java @@ -332,6 +332,11 @@ public static String[] buildCompilerArguments( CompilerConfiguration config, Str args.add( "-parameters" ); } + if ( config.isEnablePreview() ) + { + args.add( "--enable-preview" ); + } + if ( config.isShowDeprecation() ) { args.add( "-deprecation" );