Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GraalVM installation check lazy #345

Merged
merged 1 commit into from Oct 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -92,8 +92,6 @@ static String testIdsDirectory(String baseDir) {
return baseDir + File.separator + "test-ids";
}

private static String graalvmJava;

static String buildAgentArgument(String baseDir, Context context, List<String> agentOptions) {
List<String> options = new ArrayList<>(agentOptions);
String effectiveOutputDir = agentOutputDirectoryFor(baseDir, context);
Expand All @@ -117,12 +115,6 @@ static String agentOutputDirectoryFor(String baseDir, Context context) {

@Override
public void afterProjectsRead(MavenSession session) {
try {
graalvmJava = Utils.getNativeImage(logger).getParent().resolve("java").toString();
} catch (MojoExecutionException e) {
throw new RuntimeException(e);
}

for (MavenProject project : session.getProjects()) {
Build build = project.getBuild();
withPlugin(build, "native-maven-plugin", nativePlugin -> {
Expand Down Expand Up @@ -167,7 +159,7 @@ public void afterProjectsRead(MavenSession session) {
for (Xpp3Dom child : children) {
commandlineArgs.addChild(child);
}
findOrAppend(config, "executable").setValue(graalvmJava);
findOrAppend(config, "executable").setValue(getGraalvmJava());
}
})
);
Expand Down Expand Up @@ -321,7 +313,7 @@ private static void configureAgentForSurefire(Plugin surefirePlugin, String agen
Xpp3Dom argLine = new Xpp3Dom("argLine");
argLine.setValue(agentArgument);
configuration.addChild(argLine);
findOrAppend(configuration, "jvm").setValue(graalvmJava);
findOrAppend(configuration, "jvm").setValue(getGraalvmJava());
});
}

Expand Down Expand Up @@ -360,4 +352,12 @@ private static Xpp3Dom findOrAppend(Xpp3Dom parent, String childName) {
return child;
}

private static String getGraalvmJava() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Shouldn't this better be camel-cased like getGraalVmJava?

try {
return Utils.getNativeImage(logger).getParent().resolve("java").toString();
} catch (MojoExecutionException e) {
throw new RuntimeException(e);
}
}

}