@@ -87,6 +87,7 @@ public abstract class AbstractNativeImageMojo extends AbstractNativeMojo {
8787 protected static final String NATIVE_IMAGE_META_INF = "META-INF/native-image" ;
8888 protected static final String NATIVE_IMAGE_PROPERTIES_FILENAME = "native-image.properties" ;
8989 protected static final String NATIVE_IMAGE_DRY_RUN = "nativeDryRun" ;
90+ private String nativeImageVersionInformation = null ;
9091
9192 @ Parameter (defaultValue = "${plugin}" , readonly = true ) // Maven 3 only
9293 protected PluginDescriptor plugin ;
@@ -437,6 +438,21 @@ protected void checkRequiredVersionIfNeeded() throws MojoExecutionException {
437438 if (requiredVersion == null ) {
438439 return ;
439440 }
441+ NativeImageUtils .checkVersion (requiredVersion , getVersionInformation ());
442+ }
443+
444+ protected boolean isOracleGraalVM () throws MojoExecutionException {
445+ return getVersionInformation ().contains ("Oracle GraalVM" );
446+ }
447+
448+ /**
449+ * Returns the output of calling "native-image --version".
450+ */
451+ protected String getVersionInformation () throws MojoExecutionException {
452+ if (nativeImageVersionInformation != null ) {
453+ return nativeImageVersionInformation ;
454+ }
455+
440456 Path nativeImageExecutable = NativeImageConfigurationUtils .getNativeImage (logger );
441457 try {
442458 ProcessBuilder processBuilder = new ProcessBuilder (nativeImageExecutable .toString ());
@@ -447,12 +463,11 @@ protected void checkRequiredVersionIfNeeded() throws MojoExecutionException {
447463 throw new MojoExecutionException ("Execution of " + commandString + " returned non-zero result" );
448464 }
449465 InputStream inputStream = versionCheckProcess .getInputStream ();
450- String versionToCheck = new BufferedReader (
466+ nativeImageVersionInformation = new BufferedReader (
451467 new InputStreamReader (inputStream , StandardCharsets .UTF_8 ))
452468 .lines ()
453469 .collect (Collectors .joining ("\n " ));
454- NativeImageUtils .checkVersion (requiredVersion , versionToCheck );
455-
470+ return nativeImageVersionInformation ;
456471 } catch (IOException | InterruptedException e ) {
457472 throw new MojoExecutionException ("Checking GraalVM version with " + nativeImageExecutable + " failed" , e );
458473 }
0 commit comments