Skip to content

Commit a658ffa

Browse files
Allow Graal location to be set via system property
1 parent e0a9ad7 commit a658ffa

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

examples/permissive/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
</goals>
121121
<configuration>
122122
<reportErrorsAtRuntime>true</reportErrorsAtRuntime>
123+
<graalvmHome>${graalvmHome}</graalvmHome>
123124
</configuration>
124125
</execution>
125126
</executions>

examples/strict/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
<configuration>
169169
<cleanupServer>true</cleanupServer>
170170
<enableHttpUrlHandler>true</enableHttpUrlHandler>
171+
<graalvmHome>${graalvmHome}</graalvmHome>
171172
</configuration>
172173
</execution>
173174
</executions>

maven/src/main/java/org/jboss/shamrock/maven/NativeImageMojo.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.File;
44
import java.util.ArrayList;
55
import java.util.Collections;
6+
import java.util.HashMap;
67
import java.util.List;
78

89
import org.apache.maven.plugin.AbstractMojo;
@@ -47,20 +48,24 @@ public class NativeImageMojo extends AbstractMojo {
4748
@Parameter
4849
private boolean enableHttpUrlHandler;
4950

51+
@Parameter(defaultValue = "${env.GRAALVM_HOME}")
52+
private String graalvmHome;
53+
5054
@Override
5155
public void execute() throws MojoExecutionException, MojoFailureException {
5256

57+
HashMap<String, String> env = new HashMap<>(System.getenv());
5358
List<String> nativeImage;
5459
String graalvmCmd = System.getenv("GRAALVM_NATIVE_IMAGE_CMD");
5560
if (graalvmCmd != null) {
5661
// E.g. "/usr/bin/docker run -v {{PROJECT_DIR}}:/project --rm protean/graalvm-native-image"
5762
nativeImage = new ArrayList<>();
5863
Collections.addAll(nativeImage, graalvmCmd.replace("{{PROJECT_DIR}}", outputDirectory.getAbsolutePath()).split(" "));
5964
} else {
60-
String graalvmHome = System.getenv("GRAALVM_HOME");
6165
if (graalvmHome == null) {
6266
throw new MojoFailureException("GRAALVM_HOME was not set");
6367
}
68+
env.put("GRAALVM_HOME", graalvmHome);
6469
nativeImage = Collections.singletonList(graalvmHome + File.separator + "bin" + File.separator + "native-image");
6570
}
6671

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
<javax.persistence-api.version>2.2</javax.persistence-api.version>
5858
<rxjava.version>2.1.12</rxjava.version>
5959
<microprofile-rest-client-api.version>1.0</microprofile-rest-client-api.version>
60+
61+
62+
<graalvmHome>${env.GRAALVM_HOME}</graalvmHome>
6063
</properties>
6164

6265
<modules>

0 commit comments

Comments
 (0)