Skip to content

Commit

Permalink
Merge pull request #946 from gsmet/quarkus-3.3.1
Browse files Browse the repository at this point in the history
Upgrade to Quarkus 3.3.1
  • Loading branch information
gsmet authored Aug 29, 2023
2 parents 5844f67 + 184527c commit 1562880
Show file tree
Hide file tree
Showing 8 changed files with 1,288 additions and 1,301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ private MavenArtifactResolver artifactResolver(QuarkusBootstrapMojo mojo, Launch
.setUserSettings(mojo.mavenSession().getRequest().getUserSettingsFile())
.setCurrentProject(mojo.mavenProject().getFile().toString())
.setPreferPomsFromWorkspace(true)
.setProjectModelProvider(getProjectMap(mojo.mavenSession())::get));
.setProjectModelProvider(getProjectMap(mojo.mavenSession())::get)
// pass the repositories since Maven extensions could manipulate repository configs
.setRemoteRepositories(mojo.remoteRepositories()));
}
// PROD packaging mode with workspace discovery disabled
return MavenArtifactResolver.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package io.quarkus.maven;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -23,7 +18,6 @@
import io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.deployment.configuration.tracker.ConfigTrackingWriter;
import io.quarkus.runtime.LaunchMode;

/**
Expand Down Expand Up @@ -58,6 +52,12 @@ public class TrackConfigChangesMojo extends QuarkusBootstrapMojo {
@Parameter(property = "quarkus.recorded-build-config.file", required = false)
File recordedBuildConfigFile;

/**
* Whether to dump the current build configuration in case the configuration from the previous build isn't found
*/
@Parameter(defaultValue = "false", property = "quarkus.track-config-changes.dump-current-when-recorded-unavailable")
boolean dumpCurrentWhenRecordedUnavailable;

@Override
protected boolean beforeExecute() throws MojoExecutionException, MojoFailureException {
if (skip) {
Expand Down Expand Up @@ -102,16 +102,17 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
compareFile = recordedBuildConfigDirectory.toPath().resolve(this.recordedBuildConfigFile.toPath());
}

if (!Files.exists(compareFile)) {
final Properties compareProps = new Properties();
if (Files.exists(compareFile)) {
try (BufferedReader reader = Files.newBufferedReader(compareFile)) {
compareProps.load(reader);
} catch (IOException e) {
throw new RuntimeException("Failed to read " + compareFile, e);
}
} else if (!dumpCurrentWhenRecordedUnavailable) {
getLog().info(compareFile + " not found");
return;
}
final Properties compareProps = new Properties();
try (BufferedReader reader = Files.newBufferedReader(compareFile)) {
compareProps.load(reader);
} catch (IOException e) {
throw new RuntimeException("Failed to read " + compareFile, e);
}

CuratedApplication curatedApplication = null;
QuarkusClassLoader deploymentClassLoader = null;
Expand All @@ -124,11 +125,11 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
Thread.currentThread().setContextClassLoader(deploymentClassLoader);

final Class<?> codeGenerator = deploymentClassLoader.loadClass("io.quarkus.deployment.CodeGenerator");
final Method dumpConfig = codeGenerator.getMethod("readCurrentConfigValues", ApplicationModel.class, String.class,
Properties.class, QuarkusClassLoader.class, Properties.class);
actualProps = (Properties) dumpConfig.invoke(null, curatedApplication.getApplicationModel(),
final Method dumpConfig = codeGenerator.getMethod("dumpCurrentConfigValues", ApplicationModel.class, String.class,
Properties.class, QuarkusClassLoader.class, Properties.class, Path.class);
dumpConfig.invoke(null, curatedApplication.getApplicationModel(),
launchMode.name(), getBuildSystemProperties(true),
deploymentClassLoader, compareProps);
deploymentClassLoader, compareProps, targetFile);
} catch (Exception any) {
throw new MojoExecutionException("Failed to bootstrap Quarkus application", any);
} finally {
Expand All @@ -140,24 +141,5 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
deploymentClassLoader.close();
}
}

final List<String> names = new ArrayList<>(actualProps.stringPropertyNames());
Collections.sort(names);

final Path outputDir = targetFile.getParent();
if (outputDir != null && !Files.exists(outputDir)) {
try {
Files.createDirectories(outputDir);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
try (BufferedWriter writer = Files.newBufferedWriter(targetFile)) {
for (var name : names) {
ConfigTrackingWriter.write(writer, name, actualProps.getProperty(name));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.quarkus.devtools.commands.data.QuarkusCommandOutcome;
import io.quarkus.devtools.project.QuarkusProject;
import io.quarkus.devtools.project.QuarkusProjectHelper;
import io.quarkus.devtools.project.update.rewrite.QuarkusUpdateExitErrorException;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.registry.RegistryResolutionException;
import io.quarkus.registry.catalog.ExtensionCatalog;
Expand Down Expand Up @@ -129,10 +130,12 @@ protected void processProjectState(QuarkusProject quarkusProject) throws MojoExe
final QuarkusCommandOutcome result = invoker.execute();
if (!result.isSuccess()) {
throw new MojoExecutionException(
"The command did not succeed.");
"Failed to apply the updates.");
}
} catch (QuarkusUpdateExitErrorException e) {
throw new MojoExecutionException(e.getMessage());
} catch (QuarkusCommandException e) {
throw new MojoExecutionException("Failed to resolve the available updates", e);
throw new MojoExecutionException("Failed to apply the updates", e);
}
}

Expand Down
Loading

0 comments on commit 1562880

Please sign in to comment.