Skip to content

Commit

Permalink
Upgrade to Quarkus 3.14.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Sep 14, 2024
1 parent 4ee1af3 commit 00b775d
Show file tree
Hide file tree
Showing 7 changed files with 1,408 additions and 1,426 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package io.quarkus.maven;

import static io.quarkus.devtools.project.CodestartResourceLoadersBuilder.getCodestartResourceLoaders;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.maven.execution.MavenSession;
Expand All @@ -18,24 +15,23 @@
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.impl.RemoteRepositoryManager;
import org.eclipse.aether.repository.RemoteRepository;

import io.quarkus.bootstrap.BootstrapConstants;
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.devtools.messagewriter.MessageWriter;
import io.quarkus.devtools.project.BuildTool;
import io.quarkus.devtools.project.CodestartResourceLoadersBuilder;
import io.quarkus.devtools.project.JavaVersion;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.devtools.project.QuarkusProjectHelper;
import io.quarkus.devtools.project.buildfile.MavenProjectBuildFile;
import io.quarkus.maven.components.QuarkusWorkspaceProvider;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.maven.utilities.MojoUtils;
import io.quarkus.platform.descriptor.loader.json.ResourceLoader;
import io.quarkus.platform.tools.ToolsConstants;
import io.quarkus.platform.tools.ToolsUtils;
Expand All @@ -56,9 +52,6 @@ public abstract class QuarkusProjectMojoBase extends AbstractMojo {
@Parameter(defaultValue = "${session}", readonly = true)
MavenSession session;

@Component
protected RepositorySystem repoSystem;

@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
protected RepositorySystemSession repoSession;

Expand All @@ -75,7 +68,7 @@ public abstract class QuarkusProjectMojoBase extends AbstractMojo {
private String bomVersion;

@Component
RemoteRepositoryManager remoteRepositoryManager;
QuarkusWorkspaceProvider workspaceProvider;

private List<ArtifactCoords> importedPlatforms;

Expand Down Expand Up @@ -108,10 +101,14 @@ public void execute() throws MojoExecutionException {
throw new MojoExecutionException("Failed to initialize Quarkus Maven extension manager", e);
}
} else {
final List<ResourceLoader> codestartsResourceLoader = getCodestartResourceLoaders(resolveExtensionCatalog());
quarkusProject = QuarkusProject.of(baseDir(), resolveExtensionCatalog(),
codestartsResourceLoader,
log, buildTool, JavaVersion.NA);
final ExtensionCatalog extensionCatalog = resolveExtensionCatalog();
final List<ResourceLoader> codestartsResourceLoader = CodestartResourceLoadersBuilder
.codestartLoadersBuilder()
.artifactResolver(artifactResolver())
.catalog(extensionCatalog)
.build();
quarkusProject = QuarkusProject.of(baseDir(), extensionCatalog,
codestartsResourceLoader, log, buildTool, JavaVersion.NA);
}

doExecute(quarkusProject, getMessageWriter());
Expand Down Expand Up @@ -155,7 +152,7 @@ protected List<ArtifactCoords> getImportedPlatforms() throws MojoExecutionExcept
if (importedPlatforms == null) {
if (project.getFile() == null) {
if (bomGroupId == null && bomArtifactId == null && bomVersion == null) {
return Collections.emptyList();
return List.of();
}
final ExtensionCatalogResolver catalogResolver = getExtensionCatalogResolver();
if (!catalogResolver.hasRegistries()) {
Expand All @@ -172,39 +169,35 @@ protected List<ArtifactCoords> getImportedPlatforms() throws MojoExecutionExcept
} catch (RegistryResolutionException e) {
throw new MojoExecutionException("Failed to resolve the catalog of Quarkus platforms", e);
}
return importedPlatforms = Collections.singletonList(platformBom);
return importedPlatforms = List.of(platformBom);
}
importedPlatforms = collectImportedPlatforms();
}
return importedPlatforms;
}

protected MavenArtifactResolver catalogArtifactResolver() throws MojoExecutionException {
return artifactResolver;
return artifactResolver();
}

protected MavenArtifactResolver artifactResolver() throws MojoExecutionException {
return artifactResolver == null ? artifactResolver = initArtifactResolver() : artifactResolver;
}

protected MavenArtifactResolver initArtifactResolver() throws MojoExecutionException {
try {
return MavenArtifactResolver.builder()
.setRepositorySystem(repoSystem)
.setRepositorySystemSession(
getLog().isDebugEnabled() ? repoSession : MojoUtils.muteTransferListener(repoSession))
.setRemoteRepositories(repos)
.setRemoteRepositoryManager(remoteRepositoryManager)
.build();
} catch (BootstrapMavenException e) {
throw new MojoExecutionException("Failed to initialize Maven artifact resolver", e);
}
var config = BootstrapMavenContext.config()
.setArtifactTransferLogging(getLog().isDebugEnabled())
.setRemoteRepositoryManager(workspaceProvider.getRemoteRepositoryManager())
.setRepositorySystem(workspaceProvider.getRepositorySystem())
.setRemoteRepositories(repos)
.setWorkspaceDiscovery(false)
.setRepositorySystemSession(repoSession);
return workspaceProvider.createArtifactResolver(config);
}

private List<ArtifactCoords> collectImportedPlatforms()
throws MojoExecutionException {
private List<ArtifactCoords> collectImportedPlatforms() {
final List<ArtifactCoords> descriptors = new ArrayList<>(4);
final List<Dependency> constraints = project.getDependencyManagement() == null ? Collections.emptyList()
final List<Dependency> constraints = project.getDependencyManagement() == null ? List.of()
: project.getDependencyManagement().getDependencies();
if (!constraints.isEmpty()) {
final MessageWriter log = getMessageWriter();
Expand All @@ -222,17 +215,6 @@ private List<ArtifactCoords> collectImportedPlatforms()
return descriptors;
}

private String getQuarkusCoreVersion() {
final List<Dependency> constraints = project.getDependencyManagement() == null ? Collections.emptyList()
: project.getDependencyManagement().getDependencies();
for (Dependency d : constraints) {
if (d.getArtifactId().endsWith("quarkus-core") && d.getGroupId().equals("io.quarkus")) {
return d.getVersion();
}
}
return null;
}

protected void validateParameters() throws MojoExecutionException {
}

Expand All @@ -241,8 +223,8 @@ protected abstract void doExecute(QuarkusProject quarkusProject, MessageWriter l

private Artifact projectArtifact() {
return projectArtifact == null
? projectArtifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), null, "pom",
project.getVersion())
? projectArtifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), null,
ArtifactCoords.TYPE_POM, project.getVersion())
: projectArtifact;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected MavenArtifactResolver catalogArtifactResolver() throws MojoExecutionEx
protected MavenArtifactResolver initArtifactResolver() throws MojoExecutionException {
return workspaceProvider.createArtifactResolver(BootstrapMavenContext.config()
.setUserSettings(session.getRequest().getUserSettingsFile())
.setRemoteRepositoryManager(remoteRepositoryManager)
.setRemoteRepositoryManager(workspaceProvider.getRemoteRepositoryManager())
// The system needs to be initialized with the bootstrap model builder to properly interpolate system properties set on the command line
// e.g. -Dquarkus.platform.version=xxx
//.setRepositorySystem(workspaceProvider.getRepositorySystem())
Expand Down
Loading

0 comments on commit 00b775d

Please sign in to comment.