From a66eaf41230a9896c6f279fadecf3e48849f38a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Fri, 26 Jan 2024 15:11:47 +0100 Subject: [PATCH] Add ext list cmd retry and logging for failed command --- pom.xml | 6 ++--- .../maven/MavenGetQuarkusExtensions.java | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 92be4b3..011fa03 100644 --- a/pom.xml +++ b/pom.xml @@ -164,10 +164,8 @@ ${quarkus.version} - junit.jupiter.execution.parallel.enabled = true - junit.jupiter.execution.parallel.mode.default = concurrent - junit.jupiter.execution.parallel.mode.classes.default = same_thread - + + junit.jupiter.execution.parallel.enabled = true junit.jupiter.execution.parallel.mode.default = concurrent junit.jupiter.execution.parallel.mode.classes.default = same_thread diff --git a/src/main/java/quarkus/extensions/combinator/maven/MavenGetQuarkusExtensions.java b/src/main/java/quarkus/extensions/combinator/maven/MavenGetQuarkusExtensions.java index 1b6ebbc..20229f4 100644 --- a/src/main/java/quarkus/extensions/combinator/maven/MavenGetQuarkusExtensions.java +++ b/src/main/java/quarkus/extensions/combinator/maven/MavenGetQuarkusExtensions.java @@ -1,23 +1,43 @@ package quarkus.extensions.combinator.maven; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.logging.Logger; import quarkus.extensions.combinator.Configuration; import quarkus.extensions.combinator.utils.CommandBuilder; public class MavenGetQuarkusExtensions extends MavenCommand { + private static final Logger LOG = Logger.getLogger(MavenGetQuarkusExtensions.class.getName()); private final List extensions = new ArrayList<>(); public List getExtensions() { extensions.clear(); String quarkusMavenPlugin = getQuarkusMavenPlugin(); - runMavenCommandAndWait("-f", "target/test-classes/list-extensions.pom.xml", quarkusMavenPlugin + ":list-extensions", - "-Dformat=id"); + withRetry(() -> runMavenCommandAndWait("-f", "target/test-classes/list-extensions.pom.xml", + quarkusMavenPlugin + ":list-extensions", "-Dformat=id"), 3); return extensions; } + private void withRetry(Runnable cmd, int retryCount) { + int i = 1; + while (retryCount >= i++) { + try { + cmd.run(); + } catch (RuntimeException e) { + LOG.severe("Output of failed Maven command: " + Arrays.toString(extensions.toArray())); + if (retryCount < i) { + throw e; + } + extensions.clear(); + continue; + } + break; + } + } + private String getQuarkusMavenPlugin() { return Configuration.QUARKUS_MAVEN_PLUGIN.get() + ":" + Configuration.QUARKUS_VERSION.get(); }