Skip to content

Commit

Permalink
Merge pull request #35576 from gsmet/3.3.1-backports-1
Browse files Browse the repository at this point in the history
3.3.1 backports 1
  • Loading branch information
gsmet authored Aug 27, 2023
2 parents f53ee01 + 4278e56 commit e30ec8d
Show file tree
Hide file tree
Showing 106 changed files with 1,502 additions and 374 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-actions-incremental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:
echo 'EOF' >> $GITHUB_OUTPUT
- name: Tar Maven Repo
shell: bash
run: tar -I 'pigz -9' -cf maven-repo.tgz -C ~ .m2/repository
run: tar -czf maven-repo.tgz -C ~ .m2/repository
- name: Persist Maven Repo
uses: actions/upload-artifact@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parsson.version>1.1.2</parsson.version>
<resteasy-microprofile.version>2.1.1.Final</resteasy-microprofile.version>
<resteasy-spring-web.version>3.0.2.Final</resteasy-spring-web.version>
<resteasy.version>6.2.4.Final</resteasy.version>
<resteasy.version>6.2.5.Final</resteasy.version>
<opentracing.version>0.33.0</opentracing.version>
<opentracing-jdbc.version>0.2.4</opentracing-jdbc.version>
<opentracing-kafka.version>0.1.15</opentracing-kafka.version>
Expand Down Expand Up @@ -54,7 +54,7 @@
<smallrye-config.version>3.3.3</smallrye-config.version>
<smallrye-health.version>4.0.4</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.5.0</smallrye-open-api.version>
<smallrye-open-api.version>3.5.1</smallrye-open-api.version>
<smallrye-graphql.version>2.3.0</smallrye-graphql.version>
<smallrye-opentracing.version>3.0.3</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>6.2.6</smallrye-fault-tolerance.version>
Expand Down Expand Up @@ -105,11 +105,11 @@
<hibernate-reactive.version>2.0.4.Final</hibernate-reactive.version>
<hibernate-validator.version>8.0.1.Final</hibernate-validator.version>
<!-- When updating, align hibernate-search.version-for-documentation in docs/pom.xml -->
<hibernate-search.version>6.2.0.Final</hibernate-search.version>
<hibernate-search.version>6.2.1.Final</hibernate-search.version>
<narayana.version>7.0.0.Final</narayana.version>
<agroal.version>2.1</agroal.version>
<jboss-transaction-spi.version>8.0.0.Final</jboss-transaction-spi.version>
<elasticsearch-opensource-components.version>8.8.2</elasticsearch-opensource-components.version>
<elasticsearch-opensource-components.version>8.9.1</elasticsearch-opensource-components.version>
<rxjava.version>2.2.21</rxjava.version>
<wildfly.openssl-java.version>2.2.5.Final</wildfly.openssl-java.version>
<wildfly.openssl-linux.version>2.2.2.Final</wildfly.openssl-linux.version>
Expand Down Expand Up @@ -139,7 +139,7 @@
<rest-assured.version>5.3.0</rest-assured.version>
<junit.jupiter.version>5.9.3</junit.jupiter.version>
<junit-pioneer.version>1.5.0</junit-pioneer.version>
<infinispan.version>14.0.13.Final</infinispan.version>
<infinispan.version>14.0.14.Final</infinispan.version>
<infinispan.protostream.version>4.6.2.Final</infinispan.protostream.version>
<caffeine.version>3.1.5</caffeine.version>
<netty.version>4.1.94.Final</netty.version>
Expand Down
2 changes: 0 additions & 2 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<!-- Maven plugin versions -->

<!-- These properties are needed in order for them to be resolvable by the generated projects -->
<!-- Quarkus uses jboss-parent and it comes with 3.8.1-jboss-1, we don't want that in the templates -->
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<kotlin.version>1.9.0</kotlin.version>
<dokka.version>1.8.20</dokka.version>
Expand All @@ -28,7 +27,6 @@
<!-- not pretty but this is used in the codestarts and we don't want to break compatibility -->
<scala-plugin.version>${scala-maven-plugin.version}</scala-plugin.version>

<!-- version.* properties are defined in jboss-parent and are overridden/updated here: -->
<version.enforcer.plugin>3.2.1</version.enforcer.plugin>
<version.surefire.plugin>3.1.2</version.surefire.plugin>
<version.exec.plugin>3.0.0</version.exec.plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public interface Capability {

String HAL = QUARKUS_PREFIX + ".hal";

String REACTIVE_ROUTES = QUARKUS_PREFIX + ".reactive-routes";

String REST = QUARKUS_PREFIX + ".rest";
String REST_CLIENT = REST + ".client";
String REST_CLIENT_REACTIVE = REST_CLIENT + ".reactive";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.quarkus.deployment;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand All @@ -14,6 +16,7 @@
import java.util.ServiceLoader;
import java.util.StringJoiner;
import java.util.function.Consumer;
import java.util.function.Function;

import org.eclipse.microprofile.config.Config;
import org.jboss.logging.Logger;
Expand All @@ -24,14 +27,17 @@
import io.quarkus.bootstrap.prebuild.CodeGenException;
import io.quarkus.deployment.codegen.CodeGenData;
import io.quarkus.deployment.configuration.BuildTimeConfigurationReader;
import io.quarkus.deployment.configuration.tracker.ConfigTrackingConfig;
import io.quarkus.deployment.configuration.tracker.ConfigTrackingValueTransformer;
import io.quarkus.deployment.configuration.tracker.ConfigTrackingWriter;
import io.quarkus.deployment.dev.DevModeContext;
import io.quarkus.deployment.dev.DevModeContext.ModuleInfo;
import io.quarkus.maven.dependency.ResolvedDependency;
import io.quarkus.paths.OpenPathTree;
import io.quarkus.paths.PathCollection;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.util.ClassPathUtils;
import io.smallrye.config.SmallRyeConfig;

/**
* A set of methods to initialize and execute {@link CodeGenProvider}s.
Expand Down Expand Up @@ -187,47 +193,104 @@ public static boolean trigger(ClassLoader deploymentClassLoader,
}

/**
* Initializes an application build time configuration and returns current values of properties
* passed in as {@code originalProperties}.
* Initializes an application build time configuration and dumps current values of properties
* passed in as {@code previouslyRecordedProperties} to a file.
*
* @param appModel application model
* @param launchMode launch mode
* @param buildSystemProps build system (or project) properties
* @param deploymentClassLoader build classloader
* @param originalProperties properties to read from the initialized configuration
* @return current values of the passed in original properties
* @param previouslyRecordedProperties properties to read from the initialized configuration
* @param outputFile output file
*/
public static Properties readCurrentConfigValues(ApplicationModel appModel, String launchMode,
Properties buildSystemProps,
QuarkusClassLoader deploymentClassLoader, Properties originalProperties) {
public static void dumpCurrentConfigValues(ApplicationModel appModel, String launchMode, Properties buildSystemProps,
QuarkusClassLoader deploymentClassLoader, Properties previouslyRecordedProperties,
Path outputFile) {
final LaunchMode mode = LaunchMode.valueOf(launchMode);
if (previouslyRecordedProperties.isEmpty()) {
try {
readConfig(appModel, mode, buildSystemProps, deploymentClassLoader, configReader -> {
var config = configReader.initConfiguration(mode, buildSystemProps, appModel.getPlatformProperties());
final Map<String, String> allProps = new HashMap<>();
for (String name : config.getPropertyNames()) {
allProps.put(name, ConfigTrackingValueTransformer.asString(config.getConfigValue(name)));
}
ConfigTrackingWriter.write(allProps,
config.unwrap(SmallRyeConfig.class).getConfigMapping(ConfigTrackingConfig.class),
configReader.readConfiguration(config),
outputFile);
return null;
});
} catch (CodeGenException e) {
throw new RuntimeException("Failed to load application configuration", e);
}
return;
}
Config config = null;
try {
config = getConfig(appModel, LaunchMode.valueOf(launchMode), buildSystemProps, deploymentClassLoader);
config = getConfig(appModel, mode, buildSystemProps, deploymentClassLoader);
} catch (CodeGenException e) {
throw new RuntimeException("Failed to load application configuration", e);
}
var valueTransformer = ConfigTrackingValueTransformer.newInstance(config);
final Properties currentValues = new Properties(originalProperties.size());
for (var originalProp : originalProperties.entrySet()) {
var name = originalProp.getKey().toString();
final Properties currentValues = new Properties(previouslyRecordedProperties.size());
for (var prevProp : previouslyRecordedProperties.entrySet()) {
var name = prevProp.getKey().toString();
var currentValue = config.getConfigValue(name);
final String current = valueTransformer.transform(name, currentValue);
if (!originalProp.getValue().equals(current)) {
log.info("Option " + name + " has changed since the last build from "
+ originalProp.getValue() + " to " + current);
var originalValue = prevProp.getValue();
if (!originalValue.equals(current)) {
log.info("Option " + name + " has changed since the last build from " + originalValue + " to " + current);
}
if (current != null) {
currentValues.put(name, current);
}
}
return currentValues;

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

final Path outputDir = outputFile.getParent();
if (outputDir != null && !Files.exists(outputDir)) {
try {
Files.createDirectories(outputDir);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
try (BufferedWriter writer = Files.newBufferedWriter(outputFile)) {
for (var name : names) {
ConfigTrackingWriter.write(writer, name, currentValues.getProperty(name));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

public static Config getConfig(ApplicationModel appModel, LaunchMode launchMode, Properties buildSystemProps,
QuarkusClassLoader deploymentClassLoader) throws CodeGenException {
return readConfig(appModel, launchMode, buildSystemProps, deploymentClassLoader,
configReader -> configReader.initConfiguration(launchMode, buildSystemProps, appModel.getPlatformProperties()));
}

public static <T> T readConfig(ApplicationModel appModel, LaunchMode launchMode, Properties buildSystemProps,
QuarkusClassLoader deploymentClassLoader, Function<BuildTimeConfigurationReader, T> function)
throws CodeGenException {
final Map<String, List<String>> unavailableConfigServices = getUnavailableConfigServices(appModel.getAppArtifact(),
deploymentClassLoader);
final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
if (!unavailableConfigServices.isEmpty()) {
var sb = new StringBuilder();
sb.append(
"The following services are not (yet) available and will be disabled during configuration initialization at the current build phase:");
for (Map.Entry<String, List<String>> missingService : unavailableConfigServices.entrySet()) {
sb.append(System.lineSeparator());
for (String s : missingService.getValue()) {
sb.append("- ").append(s);
}
}
log.warn(sb.toString());

final Map<String, List<String>> allConfigServices = new HashMap<>(unavailableConfigServices.size());
final Map<String, byte[]> allowedConfigServices = new HashMap<>(unavailableConfigServices.size());
final Map<String, byte[]> bannedConfigServices = new HashMap<>(unavailableConfigServices.size());
Expand Down Expand Up @@ -266,14 +329,15 @@ public static Config getConfig(ApplicationModel appModel, LaunchMode launchMode,
configClBuilder.addBannedElement(new MemoryClassPathElement(bannedConfigServices, true));
}
deploymentClassLoader = configClBuilder.build();
Thread.currentThread().setContextClassLoader(deploymentClassLoader);
}
try {
return new BuildTimeConfigurationReader(deploymentClassLoader).initConfiguration(launchMode, buildSystemProps,
appModel.getPlatformProperties());
return function.apply(new BuildTimeConfigurationReader(deploymentClassLoader));
} catch (Exception e) {
throw new CodeGenException("Failed to initialize application configuration", e);
} finally {
if (!unavailableConfigServices.isEmpty()) {
Thread.currentThread().setContextClassLoader(originalClassLoader);
deploymentClassLoader.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public static ConfigTrackingValueTransformer newInstance(ConfigTrackingConfig co
* @return non-null string value for a given {@link org.eclipse.microprofile.config.ConfigValue} instance
*/
public static String asString(ConfigValue value) {
return value == null ? NOT_CONFIGURED : value.getValue();
if (value == null) {
return NOT_CONFIGURED;
}
var strValue = value.getValue();
return strValue == null ? NOT_CONFIGURED : strValue;
}

private final String userHomeDir;
Expand Down
Loading

0 comments on commit e30ec8d

Please sign in to comment.