Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Feb 5, 2025
1 parent 667a07c commit 7b64187
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
Expand All @@ -36,6 +35,7 @@

import io.quarkus.bootstrap.BootstrapConstants;
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext;
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
import io.quarkus.bootstrap.resolver.maven.ModelResolutionTaskRunner;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,23 @@ private static void loadAndLog(Path projectDir) throws Exception {
private static void logInfo(ConfiguredProject project, BootstrapMavenContext mavenCtx, MessageWriter log) throws Exception {
var quarkusApp = getFirstQuarkusApp(project);
var startTime = System.currentTimeMillis();
var extensionCatalog = registryClient(mavenCtx, log).resolveExtensionCatalog(toArtifactCoordsList(quarkusApp.getPlatformBoms()));
var registryClient = registryClient(mavenCtx, log);
log.info("Registry client initialized in " + (System.currentTimeMillis() - startTime));
var extensionCatalog = registryClient.resolveExtensionCatalog(toArtifactCoordsList(quarkusApp.getPlatformBoms()));
log.info("Resolved catalog in " + (System.currentTimeMillis() - startTime));
}

private static List<ArtifactCoords> toArtifactCoordsList(Collection<ConfiguredBom> platformBoms) {
var result = new ArrayList<ArtifactCoords>(platformBoms.size());
for(var platformBom : platformBoms) {
for (var platformBom : platformBoms) {
result.add(platformBom.getArtifact().getEffectiveCoords());
}
return result;
}

private static ConfiguredModule getFirstQuarkusApp(ConfiguredProject project) {
for(var module : project.getModules()) {
if(module.isQuarkusApplication()) {
for (var module : project.getModules()) {
if (module.isQuarkusApplication()) {
return module;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.*;
import java.util.function.Function;

import org.eclipse.aether.artifact.DefaultArtifact;
Expand Down Expand Up @@ -594,6 +595,7 @@ public ExtensionCatalog resolveExtensionCatalog(Collection<ArtifactCoords> prefe
String quarkusVersion = null;
int platformIndex = 0;
for (ArtifactCoords bom : preferredPlatforms) {
log.info("Preferred BOM " + bom.toCompactCoords());
final List<RegistryExtensionResolver> registries;
try {
registries = filterRegistries(r -> r.checkPlatform(bom));
Expand Down Expand Up @@ -803,18 +805,34 @@ private void collectPlatformExtensions(String quarkusCoreVersion, ExtensionCatal
final int compatibilityCode = catalogBuilder.getCompatibilityCode(r.getQuarkusCoreVersion(),
r.getUpstreamQuarkusCoreVersion());

for (ArtifactCoords bom : r.getMemberBoms()) {
final ExtensionCatalog.Mutable catalog = registry.resolvePlatformExtensions(bom);
final boolean parallel = false;
var startTime = System.currentTimeMillis();
if (parallel) {
var catalogs = resolveCatalogs(registry, r.getMemberBoms());
for (var catalog : catalogs) {
if (catalog != null) {
final OriginPreference originPreference = new OriginPreference(registry.getIndex(),
platformIndex,
releaseIndex, ++memberIndex, compatibilityCode);
addOriginPreference(catalog, originPreference);
catalogBuilder.addCatalog(catalog);
}
}
} else {
for (ArtifactCoords bom : r.getMemberBoms()) {
final ExtensionCatalog.Mutable catalog = registry.resolvePlatformExtensions(bom);

if (catalog != null) {
final OriginPreference originPreference = new OriginPreference(registry.getIndex(),
platformIndex,
releaseIndex, ++memberIndex, compatibilityCode);
addOriginPreference(catalog, originPreference);
if (catalog != null) {
final OriginPreference originPreference = new OriginPreference(registry.getIndex(),
platformIndex,
releaseIndex, ++memberIndex, compatibilityCode);
addOriginPreference(catalog, originPreference);

catalogBuilder.addCatalog(catalog);
catalogBuilder.addCatalog(catalog);
}
}
}
log.info("Resolved catalogs in " + (System.currentTimeMillis() - startTime));

final String upstreamQuarkusVersion = r.getUpstreamQuarkusCoreVersion();
if (upstreamQuarkusVersion != null) {
Expand All @@ -824,6 +842,27 @@ private void collectPlatformExtensions(String quarkusCoreVersion, ExtensionCatal
}
}

private List<ExtensionCatalog.Mutable> resolveCatalogs(RegistryExtensionResolver registry,
Collection<ArtifactCoords> platformBoms) {
final CompletableFuture<ExtensionCatalog.Mutable>[] futures = new CompletableFuture[platformBoms.size()];
int i = 0;
for (var platformBom : platformBoms) {
futures[i++] = CompletableFuture.supplyAsync(() -> {
try {
return registry.resolvePlatformExtensions(platformBom);
} catch (RegistryResolutionException e) {
throw new RuntimeException(e);
}
});
}
CompletableFuture.allOf(futures).join();
final List<ExtensionCatalog.Mutable> result = new ArrayList<>(futures.length);
for (i = 0; i < futures.length; ++i) {
result.add(futures[i++].getNow(null));
}
return result;
}

private List<RegistryExtensionResolver> getRegistriesForQuarkusVersion(String quarkusCoreVersion) {
try {
return filterRegistries(r -> r.checkQuarkusVersion(quarkusCoreVersion));
Expand Down

0 comments on commit 7b64187

Please sign in to comment.