Skip to content

[3.15] Use the version of Quarkus platform recommended for the current project for recipe filtering instead of the latest version recommended by the registry #47518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public UpdateProject perModule(boolean perModule) {
return this;
}

/**
* This method is not used since currently the version passed in here might not be the final target platform version
* but the latest recommended w/o taking into account extensions found in the current project.
*
* @param targetPlatformVersion latest recommended Quarkus platform version
* @return this instance
*/
public UpdateProject targetPlatformVersion(String targetPlatformVersion) {
invocation.setValue(TARGET_PLATFORM_VERSION, targetPlatformVersion);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,30 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws
}
final ApplicationModel appModel = invocation.getValue(UpdateProject.APP_MODEL);
final ExtensionCatalog targetCatalog = invocation.getValue(UpdateProject.TARGET_CATALOG);
final String targetPlatformVersion = invocation.getValue(UpdateProject.TARGET_PLATFORM_VERSION);
final boolean perModule = invocation.getValue(UpdateProject.PER_MODULE, false);

final ProjectState currentState = resolveProjectState(appModel,
invocation.getQuarkusProject().getExtensionsCatalog());
final ArtifactCoords projectQuarkusPlatformBom = getProjectQuarkusPlatformBOM(currentState);
if (projectQuarkusPlatformBom == null) {
String error = "The project does not import any Quarkus platform BOM";
final ArtifactCoords currentQuarkusPlatformBom = getProjectQuarkusPlatformBOM(currentState);
var failure = ensureQuarkusBomVersionIsNotNull(currentQuarkusPlatformBom, invocation.log());
if (failure != null) {
return failure;
}

invocation.log().error(error);
return QuarkusCommandOutcome.failure(error);
final ProjectState recommendedState = resolveRecommendedState(currentState, targetCatalog,
invocation.log());
final ArtifactCoords recommendedQuarkusPlatformBom = getProjectQuarkusPlatformBOM(recommendedState);
failure = ensureQuarkusBomVersionIsNotNull(recommendedQuarkusPlatformBom, invocation.log());
if (failure != null) {
return failure;
}
if (Objects.equals(projectQuarkusPlatformBom.getVersion(), targetPlatformVersion)) {

if (Objects.equals(currentQuarkusPlatformBom, recommendedQuarkusPlatformBom)) {
ProjectInfoCommandHandler.logState(currentState, perModule, true, invocation.getQuarkusProject().log());
} else {
invocation.log().info("Instructions to update this project from '%s' to '%s':",
projectQuarkusPlatformBom.getVersion(), targetPlatformVersion);
currentQuarkusPlatformBom, recommendedQuarkusPlatformBom);
final QuarkusProject quarkusProject = invocation.getQuarkusProject();
final ProjectState recommendedState = resolveRecommendedState(currentState, targetCatalog,
invocation.log());
final ProjectPlatformUpdateInfo platformUpdateInfo = resolvePlatformUpdateInfo(currentState,
recommendedState);
final ProjectExtensionsUpdateInfo extensionsUpdateInfo = ProjectUpdateInfos.resolveExtensionsUpdateInfo(
Expand All @@ -89,7 +94,7 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws
logUpdates(invocation.getQuarkusProject(), currentState, recommendedState, platformUpdateInfo,
extensionsUpdateInfo,
false, perModule,
quarkusProject.log());
invocation.log());
final boolean noRewrite = invocation.getValue(UpdateProject.NO_REWRITE, false);

if (!noRewrite) {
Expand All @@ -106,8 +111,8 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws
}
QuarkusUpdates.ProjectUpdateRequest request = new QuarkusUpdates.ProjectUpdateRequest(
buildTool,
projectQuarkusPlatformBom.getVersion(),
targetPlatformVersion,
currentQuarkusPlatformBom.getVersion(),
recommendedQuarkusPlatformBom.getVersion(),
kotlinVersion,
updateJavaVersion,
extensionsUpdateInfo);
Expand Down Expand Up @@ -155,6 +160,15 @@ private static ArtifactCoords getProjectQuarkusPlatformBOM(ProjectState currentS
return null;
}

private static QuarkusCommandOutcome ensureQuarkusBomVersionIsNotNull(ArtifactCoords bomCoords, MessageWriter log) {
if (bomCoords == null) {
String error = "The project state is missing the Quarkus platform BOM";
log.error(error);
return QuarkusCommandOutcome.failure(error);
}
return null;
}

private static void logUpdates(QuarkusProject project, ProjectState currentState, ProjectState recommendedState,
ProjectPlatformUpdateInfo platformUpdateInfo,
ProjectExtensionsUpdateInfo extensionsUpdateInfo, boolean recommendState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,16 @@ private static List<ExtensionCatalog> getRecommendedOrigins(ExtensionCatalog ext
private static void addOrigins(final List<ExtensionOrigins> extOrigins, Extension e) {
ExtensionOrigins.Builder eoBuilder = null;
for (ExtensionOrigin o : e.getOrigins()) {
if (!(o instanceof ExtensionCatalog)) {
continue;
}
final ExtensionCatalog c = (ExtensionCatalog) o;
final OriginPreference op = (OriginPreference) c.getMetadata().get("origin-preference");
if (op == null) {
continue;
}
if (eoBuilder == null) {
eoBuilder = ExtensionOrigins.builder(e.getArtifact().getKey());
if (o instanceof ExtensionCatalog c) {
final OriginPreference op = (OriginPreference) c.getMetadata().get("origin-preference");
if (op == null) {
continue;
}
if (eoBuilder == null) {
eoBuilder = ExtensionOrigins.builder(e.getArtifact().getKey());
}
eoBuilder.addOrigin(c, op);
}
eoBuilder.addOrigin(c, op);
}
if (eoBuilder != null) {
extOrigins.add(eoBuilder.build());
Expand Down
Loading