This is an automated email from the ASF dual-hosted git repository.

fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 8d4209ebe40 CAMEL-22891: make the mvn command configurable
8d4209ebe40 is described below

commit 8d4209ebe40ba199b25439ce81300b27da227a61
Author: Marco Carletti <[email protected]>
AuthorDate: Thu Feb 26 11:57:47 2026 +0100

    CAMEL-22891: make the mvn command configurable
---
 tests/camel-itest-spring-boot/pom.xml              |  4 ++++
 .../common/AbstractSpringBootBaseTestSupport.java  |  9 ++++----
 .../common/ArchetypeGenerationExtension.java       | 27 ++++++++++++++--------
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/tests/camel-itest-spring-boot/pom.xml 
b/tests/camel-itest-spring-boot/pom.xml
index 9d787da438d..2940f43422b 100644
--- a/tests/camel-itest-spring-boot/pom.xml
+++ b/tests/camel-itest-spring-boot/pom.xml
@@ -35,6 +35,7 @@
     <properties>
         <archetype-common-version>3.4.1</archetype-common-version>
         <delete-after-test>true</delete-after-test>
+        <mvn-command>./mvnw</mvn-command>
     </properties>
 
     <dependencyManagement>
@@ -136,6 +137,9 @@
                         <project-version>${project.version}</project-version>
                         
<project.build.directory>${project.build.directory}</project.build.directory>
                         
<delete-after-test>${delete-after-test}</delete-after-test>
+                        <maven-version>${maven-version}</maven-version>
+                        <mvn-command>${mvn-command}</mvn-command>
+                        
<maven.multiModuleProjectDirectory>${maven.multiModuleProjectDirectory}</maven.multiModuleProjectDirectory>
                     </systemPropertyVariables>
                 </configuration>
             </plugin>
diff --git 
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
 
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
index 32af3c3226c..053b964448a 100644
--- 
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
+++ 
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
@@ -42,9 +42,6 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
 
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public abstract class AbstractSpringBootBaseTestSupport {
 
@@ -81,7 +78,7 @@ public abstract class AbstractSpringBootBaseTestSupport {
         Path projectDir = archetype.getGeneratedProject().getProjectDir();
 
         List<String> command = new ArrayList<>(List.of(
-                "mvn", "compile", "dependency:build-classpath",
+                System.getProperty("mvn-command"), "compile", 
"dependency:build-classpath",
                 "-DincludeScope=runtime",
                 "-Dmdep.outputFile=" + CLASSPATH_FILE,
                 "-B"));
@@ -90,6 +87,8 @@ public abstract class AbstractSpringBootBaseTestSupport {
             command.add("-Dmaven.repo.local=" + localRepo);
         }
 
+        LOG.debug("running: {}", String.join(" ", command));
+
         ProcessBuilder pb = new ProcessBuilder(command)
                 .directory(projectDir.toFile())
                 .redirectErrorStream(true);
@@ -97,7 +96,7 @@ public abstract class AbstractSpringBootBaseTestSupport {
         String output = new String(process.getInputStream().readAllBytes());
         int exitCode = process.waitFor();
         if (exitCode != 0) {
-            throw new RuntimeException("mvn compile dependency:build-classpath 
failed (exit code "
+            throw new RuntimeException(String.join(" ", command) + " failed 
(exit code "
                     + exitCode + ") for " + projectDir + ":\n" + output);
         }
 
diff --git 
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
 
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
index 932ab937abc..38778d4eb44 100644
--- 
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
+++ 
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.itest.springboot.common;
 
+import ch.qos.logback.classic.LoggerContext;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archetype.ArchetypeGenerationRequest;
 import org.apache.maven.archetype.ArchetypeGenerationResult;
@@ -24,15 +25,18 @@ import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
 import org.codehaus.plexus.DefaultContainerConfiguration;
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusConstants;
+import org.eclipse.aether.DefaultRepositorySystemSession;
 import org.junit.jupiter.api.extension.BeforeAllCallback;
 import org.junit.jupiter.api.extension.BeforeEachCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
 import org.junit.jupiter.api.extension.ParameterContext;
 import org.junit.jupiter.api.extension.ParameterResolver;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.InputStream;
@@ -92,6 +96,7 @@ public class ArchetypeGenerationExtension implements 
BeforeAllCallback, BeforeEa
 
     private GeneratedProject createProject() {
         try {
+            ((LoggerContext) 
LoggerFactory.getILoggerFactory()).setName(archetypeConfig.artifactId);
             Path targetDir = 
Path.of(requireSystemProperty("project.build.directory"));
             Files.createDirectories(targetDir);
             Path outputDir = Files.createTempDirectory(targetDir, 
"archetype-test-");
@@ -101,6 +106,7 @@ public class ArchetypeGenerationExtension implements 
BeforeAllCallback, BeforeEa
             DefaultPlexusContainer container = new 
DefaultPlexusContainer(config);
             ArchetypeGenerator generator = 
container.lookup(ArchetypeGenerator.class);
 
+            String mavenVersion = requireSystemProperty("maven-version");
             String archetypeVersion = requireSystemProperty("project-version");
             String camelVersion = requireSystemProperty("camel-version");
             String springBootVersion = 
requireSystemProperty("spring-boot-version");
@@ -116,6 +122,10 @@ public class ArchetypeGenerationExtension implements 
BeforeAllCallback, BeforeEa
             additionalProperties.setProperty("camel-version", camelVersion);
             additionalProperties.setProperty("spring-boot-version", 
springBootVersion);
             additionalProperties.setProperty("maven-compiler-plugin-version", 
mavenCompilerPluginVersion);
+            additionalProperties.setProperty("maven-version", mavenVersion);
+
+            DefaultRepositorySystemSession session = 
MavenRepositorySystemUtils.newSession();
+            session.setSystemProperties(System.getProperties());
 
             ArchetypeGenerationRequest request = new 
ArchetypeGenerationRequest()
                     .setArchetypeGroupId(ARCHETYPE_GROUP_ID)
@@ -126,14 +136,19 @@ public class ArchetypeGenerationExtension implements 
BeforeAllCallback, BeforeEa
                     .setVersion(archetypeConfig.version)
                     .setPackage(archetypeConfig.packageName)
                     .setOutputDirectory(outputDir.toString())
-                    .setProperties(additionalProperties);
+                    .setProperties(additionalProperties)
+                    .setRepositorySession(session);
 
             ArchetypeGenerationResult result = new ArchetypeGenerationResult();
             generator.generateArchetype(request, archetypeFile, result);
 
+            if (result.getCause() != null) {
+                throw result.getCause();
+            }
+
             Path projectDir = outputDir.resolve(archetypeConfig.artifactId);
             customizeArchetype(projectDir, archetypeConfig);
-            return new GeneratedProject(outputDir, projectDir, result);
+            return new GeneratedProject(outputDir, projectDir);
         } catch (Exception e) {
             throw new RuntimeException("Failed to generate archetype project", 
e);
         }
@@ -252,22 +267,16 @@ public class ArchetypeGenerationExtension implements 
BeforeAllCallback, BeforeEa
 
         private final Path outputDir;
         private final Path projectDir;
-        private final ArchetypeGenerationResult result;
 
-        GeneratedProject(Path outputDir, Path projectDir, 
ArchetypeGenerationResult result) {
+        GeneratedProject(Path outputDir, Path projectDir) {
             this.outputDir = outputDir;
             this.projectDir = projectDir;
-            this.result = result;
         }
 
         public Path getProjectDir() {
             return projectDir;
         }
 
-        public ArchetypeGenerationResult getResult() {
-            return result;
-        }
-
         @Override
         public void close() throws Exception {
             if (Boolean.parseBoolean(System.getProperty("delete-after-test", 
"true"))

Reply via email to