From ebe07173c46c07891de3a4b1fcd98060dcff4f6d Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Wed, 23 Oct 2024 01:42:32 +0800 Subject: [PATCH] bugfix for when config agent.metadataCopy.disabledStages have 2 custom stage elements other than main and test, it would never run correctly. --- .../graalvm/buildtools/maven/MergeAgentFilesMojo.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/MergeAgentFilesMojo.java b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/MergeAgentFilesMojo.java index f752db165..b5b9d35cd 100644 --- a/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/MergeAgentFilesMojo.java +++ b/native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/MergeAgentFilesMojo.java @@ -75,6 +75,8 @@ public class MergeAgentFilesMojo extends AbstractMergeAgentFilesMojo { private static int numberOfExecutions = 0; + private static final List DEFAULT_DIRS = Arrays.asList("main", "test"); + @Override public void execute() throws MojoExecutionException { // we need this mojo to be executed only once @@ -96,15 +98,14 @@ public void execute() throws MojoExecutionException { } List disabledPhases = agentConfiguration.getMetadataCopyConfiguration().getDisabledStages(); - if (disabledPhases.size() == 2) { + + Set dirs = new HashSet<>(DEFAULT_DIRS); + dirs.removeAll(disabledPhases); + if (dirs.isEmpty()) { logger.info("Both phases are skipped."); return; } - Set dirs = new HashSet(2); - dirs.addAll(Arrays.asList("main", "test")); - dirs.removeAll(disabledPhases); - for (String dir : dirs) { String agentOutputDirectory = (target + "/native/agent-output/" + dir).replace('/', File.separatorChar); mergeForGivenDir(agentOutputDirectory);