Repository: quarkusio/quarkus
Issue: Suspicious CI failure in AddExtensionsMojoTest.testAddSingleDependency

First, I wonder a bit why we end up having the Gradle repo in a Maven test. AFAIU, the bootstrap resolver both includes Maven and Gradle but I wonder if we could have an architecture where we have only Maven when using Maven and only Gradle when using Gradle?

Apart, from that, I think the issue is probably related to an issue with the Gradle repo... but... I don't think downloading an empty artifact is ok?

See: `Downloading from google-maven-central: https://maven-central-eu.storage-download.googleapis.com/repos/central/data///-.pom`

So I wonder if there's something fishy?

```
Downloading from gradle-official-repository: https://repo.gradle.org/gradle/libs-releases-local/io/quarkus/quarkus-bom/maven-metadata.xml
[debug] The requested Quarkus platform BOM version is available on the classpath
Downloading from google-maven-central: https://maven-central-eu.storage-download.googleapis.com/repos/central/data///-.pom
Downloading from jboss-maven-central-proxy: https://repository.jboss.org/nexus/content/repositories/central///-.pom
Downloading from gradle-official-repository: https://repo.gradle.org/gradle/libs-releases-local///-.pom
Downloading from central: https://repo.maven.apache.org/maven2///-.pom
Error:  Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 489.866 s <<< FAILURE! - in io.quarkus.maven.AddExtensionsMojoTest
Error:  io.quarkus.maven.AddExtensionsMojoTest.testAddSingleDependency  Time elapsed: 301.002 s  <<< ERROR!
org.apache.maven.plugin.MojoExecutionException: Unable to update the pom.xml file
	at io.quarkus.maven.AddExtensionMojo.doExecute(AddExtensionMojo.java:80)
	at io.quarkus.maven.QuarkusProjectMojoBase.execute(QuarkusProjectMojoBase.java:112)
	at io.quarkus.maven.AddExtensionMojoTest.testAddSingleDependency(AddExtensionMojoTest.java:51)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
Caused by: java.lang.RuntimeException: org.apache.maven.plugin.MojoExecutionException: Failed to collect dependencies for the project
	at io.quarkus.maven.QuarkusProjectMojoBase.lambda$execute$1(QuarkusProjectMojoBase.java:97)
	at io.quarkus.maven.MavenProjectBuildFile.getDependencies(MavenProjectBuildFile.java:117)
	at io.quarkus.devtools.project.buildfile.BuildFile.getDependenciesKeys(BuildFile.java:135)
	at io.quarkus.devtools.project.buildfile.BuildFile.withoutAlreadyInstalled(BuildFile.java:92)
	at io.quarkus.devtools.project.buildfile.BuildFile.install(BuildFile.java:45)
	at io.quarkus.devtools.commands.handlers.AddExtensionsCommandHandler.execute(AddExtensionsCommandHandler.java:45)
	at io.quarkus.devtools.commands.AddExtensions.execute(AddExtensions.java:56)
	at io.quarkus.maven.AddExtensionMojo.doExecute(AddExtensionMojo.java:75)
	... 70 more
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to collect dependencies for the project
	at io.quarkus.maven.QuarkusProjectMojoBase.projectDependencies(QuarkusProjectMojoBase.java:345)
	at io.quarkus.maven.QuarkusProjectMojoBase.lambda$execute$1(QuarkusProjectMojoBase.java:95)
	... 77 more
Caused by: io.quarkus.bootstrap.resolver.maven.BootstrapMavenException: Failed to collect dependencies for ::pom:
	at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.collectDependencies(MavenArtifactResolver.java:226)
	at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.collectDependencies(MavenArtifactResolver.java:216)
	at io.quarkus.maven.QuarkusProjectMojoBase.projectDependencies(QuarkusProjectMojoBase.java:329)
	... 78 more
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to read artifact descriptor for ::pom:
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:206)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:284)
	at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.collectDependencies(MavenArtifactResolver.java:224)
	... 80 more
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for ::pom:
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:200)
	... 82 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact ::pom: from/to gradle-official-repository (https://repo.gradle.org/gradle/libs-releases-local/): Transfer failed for https://repo.gradle.org/gradle/libs-releases-local////-.pom 524 Origin Time-out
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:240)
	... 84 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact ::pom: from/to gradle-official-repository (https://repo.gradle.org/gradle/libs-releases-local/): Transfer failed for https://repo.gradle.org/gradle/libs-releases-local////-.pom 524 Origin Time-out
	at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:369)
	at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:644)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:499)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
	... 87 more
Caused by: org.apache.maven.wagon.TransferFailedException: Transfer failed for https://repo.gradle.org/gradle/libs-releases-local////-.pom 524 Origin Time-out
	at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1196)
	at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1138)
	at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:126)
	at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
	at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
	at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run(WagonTransporter.java:567)
	at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:435)
	at org.eclipse.aether.transport.wagon.WagonTransporter.get(WagonTransporter.java:412)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:457)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364)
	... 92 more
```

Changed files:
independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java
integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java

diff --git a/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java b/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java
index 0c0ac849a79..406b018e54f 100644
--- a/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java
+++ b/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java
@@ -375,7 +375,8 @@ private QuarkusPlatformDescriptor resolveJsonArtifactFromBom(AppModelResolver ar
                 throw new IllegalStateException("Failed to resolve the platform BOM using the provided coordinates", e);
             }
             log.debug(
-                    "Failed to resolve Quarkus platform BOM using the default coordinates, falling back to the bundled Quarkus platform artifacts");
+                    "Failed to resolve Quarkus platform BOM using the default coordinates %s:%s:%s, falling back to the bundled Quarkus platform artifacts",
+                    bomGroupId, bomArtifactId, bomVersion);
         }
 
         Model bundledBom = loadBundledPom();
diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java b/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java
index bf2799d2323..a99524f7b5d 100644
--- a/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java
+++ b/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java
@@ -12,35 +12,90 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.model.Dependency;
+import org.apache.maven.model.DependencyManagement;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.resolution.ArtifactDescriptorResult;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext;
+import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
+import io.quarkus.bootstrap.resolver.maven.workspace.ModelUtils;
+
 class AddExtensionMojoTest {
 
-    private static final File MIN_POM = new File("src/test/resources/projects/simple-pom-it/pom.xml");
+    private static final File MIN_POM = new File("target/test-classes/projects/simple-pom-it/pom.xml");
     private static final File OUTPUT_POM = new File("target/test-classes/add-extension/pom.xml");
     private static final String DEP_GAV = "org.apache.commons:commons-lang3:3.8.1";
     private AddExtensionMojo mojo;
 
     @BeforeEach
-    void init() throws IOException {
+    void init() throws Exception {
         mojo = getMojo();
         mojo.project = new MavenProject();
         mojo.project.setPomFile(OUTPUT_POM);
         mojo.project.setFile(OUTPUT_POM);
-        Model model = new Model();
-        mojo.project.setModel(model);
-        mojo.project.setOriginalModel(model);
         FileUtils.copyFile(MIN_POM, OUTPUT_POM);
+
+        Model model = ModelUtils.readModel(OUTPUT_POM.toPath());
         model.setPomFile(OUTPUT_POM);
+        mojo.project.setOriginalModel(model);
+
+        final MavenArtifactResolver mvn = new MavenArtifactResolver(
+                new BootstrapMavenContext(BootstrapMavenContext.config()
+                        .setCurrentProject(OUTPUT_POM.getAbsolutePath())
+                        .setOffline(true)));
+        mojo.repoSystem = mvn.getSystem();
+        mojo.repoSession = mvn.getSession();
+        mojo.repos = mvn.getRepositories();
+        mojo.remoteRepositoryManager = mvn.getRemoteRepositoryManager();
+
+        final Model effectiveModel = model.clone();
+        final DependencyManagement dm = new DependencyManagement();
+        effectiveModel.setDependencyManagement(dm);
+        final Artifact projectPom = new DefaultArtifact(ModelUtils.getGroupId(model), model.getArtifactId(), null, "pom",
+                ModelUtils.getVersion(model));
+        final ArtifactDescriptorResult descriptor = mvn.resolveDescriptor(projectPom);
+        descriptor.getManagedDependencies().forEach(d -> {
+            final Dependency dep = new Dependency();
+            Artifact a = d.getArtifact();
+            dep.setGroupId(a.getGroupId());
+            dep.setArtifactId(a.getArtifactId());
+            dep.setClassifier(a.getClassifier());
+            dep.setType(a.getExtension());
+            dep.setVersion(a.getVersion());
+            if (d.getOptional() != null) {
+                dep.setOptional(d.getOptional());
+            }
+            dep.setScope(d.getScope());
+            dm.addDependency(dep);
+        });
+        descriptor.getDependencies().forEach(d -> {
+            final Dependency dep = new Dependency();
+            Artifact a = d.getArtifact();
+            dep.setGroupId(a.getGroupId());
+            dep.setArtifactId(a.getArtifactId());
+            dep.setClassifier(a.getClassifier());
+            dep.setType(a.getExtension());
+            dep.setVersion(a.getVersion());
+            if (d.getOptional() != null) {
+                dep.setOptional(d.getOptional());
+            }
+            dep.setScope(d.getScope());
+            effectiveModel.addDependency(dep);
+        });
+        descriptor.getProperties().entrySet().forEach(p -> effectiveModel.getProperties().setProperty(p.getKey(),
+                p.getValue() == null ? "" : p.getValue().toString()));
+        mojo.project.setModel(effectiveModel);
     }
 
-    protected AddExtensionMojo getMojo() {
+    protected AddExtensionMojo getMojo() throws Exception {
         return new AddExtensionMojo();
     }