Skip to content

Commit

Permalink
Merge pull request quarkusio#44079 from radcortez/fix-42114
Browse files Browse the repository at this point in the history
Move core configuration to @ConfigMapping
  • Loading branch information
gsmet authored Nov 14, 2024
2 parents 5e84cc8 + 2afeda0 commit 0e67055
Show file tree
Hide file tree
Showing 83 changed files with 589 additions and 555 deletions.
20 changes: 11 additions & 9 deletions core/deployment/src/main/java/io/quarkus/banner/BannerConfig.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package io.quarkus.banner;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

/**
* Banner
*/
@ConfigRoot(name = "banner")
public class BannerConfig {

private static final String DEFAULT_BANNER_FILE = "default_banner.txt";
@ConfigMapping(prefix = "quarkus.banner")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface BannerConfig {
String DEFAULT_BANNER_FILE = "default_banner.txt";

/**
* The path of the banner (path relative to root of classpath)
* which could be provided by user
*/
@ConfigItem(defaultValue = DEFAULT_BANNER_FILE)
public String path;
@WithDefault(DEFAULT_BANNER_FILE)
String path();

public boolean isDefaultPath() {
return DEFAULT_BANNER_FILE.equals(path);
default boolean isDefaultPath() {
return DEFAULT_BANNER_FILE.equals(path());
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
package io.quarkus.deployment;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

/**
* Bootstrap
* <p>
* This is used currently only to suppress warnings about unknown properties
* when the user supplies something like: -Dquarkus.debug.reflection=true
*/
@ConfigRoot
public class BootstrapConfig {
@ConfigMapping(prefix = "quarkus.bootstrap")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface BootstrapConfig {

/**
* If set to true, the workspace initialization will be based on the effective POMs
* (i.e. properly interpolated, including support for profiles) instead of the raw ones.
*/
@ConfigItem(defaultValue = "false")
boolean effectiveModelBuilder;
@WithDefault("false")
boolean effectiveModelBuilder();

/**
* If set to true, workspace discovery will be enabled for all launch modes.
* Usually, workspace discovery is enabled by default only for dev and test modes.
*/
@ConfigItem(defaultValue = "false")
Boolean workspaceDiscovery;
@WithDefault("false")
boolean workspaceDiscovery();

/**
* If set to true, workspace loader will log warnings for modules that could not be loaded for some reason
* instead of throwing errors.
*/
@ConfigItem(defaultValue = "false")
boolean warnOnFailingWorkspaceModules;
@WithDefault("false")
boolean warnOnFailingWorkspaceModules();

/**
* By default, the bootstrap mechanism will create a shared cache of open JARs for
Expand All @@ -40,25 +43,25 @@ public class BootstrapConfig {
* Quarkus classloaders create a new ZIP FileSystem for each JAR classpath element every time it is added
* to a Quarkus classloader.
*/
@ConfigItem(defaultValue = "false")
boolean disableJarCache;
@WithDefault("false")
boolean disableJarCache();

/**
* A temporary option introduced to avoid a logging warning when {@code -Dquarkus.bootstrap.incubating-model-resolver}
* is added to the build command line.
* This option enables an incubating implementation of the Quarkus Application Model resolver.
* This option will be removed as soon as the incubating implementation becomes the default one.
*/
@ConfigItem(defaultValue = "false")
boolean incubatingModelResolver;
@WithDefault("false")
boolean incubatingModelResolver();

/**
* Whether to throw an error, warn or silently ignore misaligned platform BOM imports
*/
@ConfigItem(defaultValue = "error")
public MisalignedPlatformImports misalignedPlatformImports;
@WithDefault("error")
MisalignedPlatformImports misalignedPlatformImports();

public enum MisalignedPlatformImports {
enum MisalignedPlatformImports {
ERROR,
WARN,
IGNORE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package io.quarkus.deployment;

import io.quarkus.runtime.annotations.ConfigDocPrefix;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;

/**
* Configuration
*/
@ConfigRoot(name = ConfigItem.PARENT, phase = ConfigPhase.BUILD_TIME)
@ConfigMapping(prefix = "quarkus.config")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
@ConfigDocPrefix("quarkus.config")
public class ConfigBuildTimeConfig {
public interface ConfigBuildTimeConfig {
/**
* <p>
* Set this to <code>true</code> to read configuration from system properties and environment variables only. This
* only applies to runtime.
* </p>
*/
@ConfigItem(name = "config.sources.system-only", defaultValue = "false")
public boolean systemOnly;
@WithName("sources.system-only")
@WithDefault("false")
boolean systemOnly();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

/**
* Debugging
Expand All @@ -13,38 +15,36 @@
*
* TODO refactor code to actually use these values
*/
@ConfigRoot
public class DebugConfig {
@ConfigMapping(prefix = "quarkus.debug")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface DebugConfig {

/**
* If set to true, writes a list of all reflective classes to META-INF
*/
@ConfigItem(defaultValue = "false")
boolean reflection;
@WithDefault("false")
boolean reflection();

/**
* If set to a directory, all generated classes will be written into that directory
*/
@ConfigItem
Optional<String> generatedClassesDir;
Optional<String> generatedClassesDir();

/**
* If set to a directory, all transformed classes (e.g. Panache entities) will be written into that directory
*/
@ConfigItem
Optional<String> transformedClassesDir;
Optional<String> transformedClassesDir();

/**
* If set to a directory, ZIG files for generated code will be written into that directory.
* <p>
* A ZIG file is a textual representation of the generated code that is referenced in the stacktraces.
*/
@ConfigItem
Optional<String> generatedSourcesDir;
Optional<String> generatedSourcesDir();

/**
* If set to true then dump the build metrics to a JSON file in the build directory.
*/
@ConfigItem(defaultValue = "false")
boolean dumpBuildMetrics;
@WithDefault("false")
boolean dumpBuildMetrics();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,32 @@
import java.util.List;
import java.util.Optional;

import org.jboss.logging.Logger;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.JniBuildItem;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;

public class JniProcessor {

private static final Logger LOGGER = Logger.getLogger(JniProcessor.class);

JniConfig jni;

/**
* JNI
*/
@ConfigMapping(prefix = "quarkus.jni")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
static class JniConfig {
interface JniConfig {
/**
* Paths of library to load.
*/
@ConfigItem
Optional<List<String>> libraryPaths;

/**
* @deprecated JNI is always enabled starting from GraalVM 19.3.1.
*/
@Deprecated
@ConfigItem(defaultValue = "true")
boolean enable = true;
Optional<List<String>> libraryPaths();
}

@BuildStep
void setupJni(BuildProducer<JniBuildItem> jniProducer) {
if (!jni.enable) {
LOGGER.warn("Your application is setting the deprecated 'quarkus.jni.enable' configuration key to false. Please"
+ " consider removing this configuration key as it is ignored (JNI is always enabled) and it will be"
+ " removed in a future Quarkus version.");
}
if (jni.libraryPaths.isPresent()) {
jniProducer.produce(new JniBuildItem(jni.libraryPaths.get()));
if (jni.libraryPaths().isPresent()) {
jniProducer.produce(new JniBuildItem(jni.libraryPaths().get()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.quarkus.deployment;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

/**
* Platform
Expand All @@ -11,24 +13,25 @@
*
* TODO refactor code to actually use these values
*/
@ConfigRoot
public class PlatformConfig {
@ConfigMapping(prefix = "quarkus.platform")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface PlatformConfig {

/**
* groupId of the platform to use
*/
@ConfigItem(defaultValue = "io.quarkus.platform")
String groupId;
@WithDefault("io.quarkus.platform")
String groupId();

/**
* artifactId of the platform to use
*/
@ConfigItem(defaultValue = "quarkus-bom")
String artifactId;
@WithDefault("quarkus-bom")
String artifactId();

/**
* version of the platform to use
*/
@ConfigItem(defaultValue = "999-SNAPSHOT")
String version;
@WithDefault("999-SNAPSHOT")
String version();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,56 @@

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

/**
* SnapStart
* <p>
* Configure the various optimization to use
* <a href="https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html">SnapStart</a>
*/
@ConfigRoot(phase = ConfigPhase.BUILD_TIME, name = "snapstart")
public class SnapStartConfig {
@ConfigMapping(prefix = "quarkus.snapstart")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface SnapStartConfig {

/**
* Enable/Disable SnapStart integration
* <p>
* Default value is dependent on extensions deployed
* (i.e. when using AWS Lambda extensions, this will be set to true by default)
*/
@ConfigItem
Optional<Boolean> enable;
Optional<Boolean> enable();

/**
* Will do a classpath search for all {@code META-INF/quarkus-preload-classes.txt} files
* These files contain fully qualified classnames that should be loaded in the SnapStart/CRaC
* {@code beforeCheckpoint()} phase.
*/
@ConfigItem(defaultValue = "true")
boolean preloadClasses;
@WithDefault("true")
boolean preloadClasses();

/**
* if preloading classes, specify whether to do static initialization when preloading these classes.
*/
@ConfigItem(defaultValue = "true")
boolean initializeClasses;
@WithDefault("true")
boolean initializeClasses();

/**
* Start the full application during the snapshotting process.
* In other words, when enabled, it performs {@code Application.start()} within SnapStart/CRaC
* {@code beforeCheckpoint()} phase.
*/
@ConfigItem(defaultValue = "true")
boolean fullWarmup;
@WithDefault("true")
boolean fullWarmup();

/**
* When SnapStart is enabled, it generates the application class list, so it can be preloaded.
* Only used if {@link #preloadClasses} is set to {@code true}.
*/
@ConfigItem(defaultValue = "true")
boolean generateApplicationClassList;
@WithDefault("true")
boolean generateApplicationClassList();

}
Loading

0 comments on commit 0e67055

Please sign in to comment.