mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Make application version and name available as runtime properties
Fixes: #6255 Co-authored-by: Guillaume Smet <guillaume.smet@gmail.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package io.quarkus.deployment.steps;
|
||||
|
||||
import io.quarkus.deployment.ApplicationConfig;
|
||||
import io.quarkus.deployment.annotations.BuildStep;
|
||||
import io.quarkus.deployment.builditem.ApplicationInfoBuildItem;
|
||||
import io.quarkus.runtime.ApplicationConfig;
|
||||
|
||||
public class ApplicationInfoBuildStep {
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ public class RuntimeRunner implements Runnable, Closeable {
|
||||
builder.setRoot(target);
|
||||
builder.setClassLoader(loader);
|
||||
builder.setLaunchMode(launchMode);
|
||||
builder.setBuildSystemProperties(buildSystemProperties);
|
||||
if (liveReloadState != null) {
|
||||
builder.setLiveReloadState(liveReloadState);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.quarkus.deployment;
|
||||
package io.quarkus.runtime;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -6,19 +6,19 @@ import io.quarkus.runtime.annotations.ConfigItem;
|
||||
import io.quarkus.runtime.annotations.ConfigPhase;
|
||||
import io.quarkus.runtime.annotations.ConfigRoot;
|
||||
|
||||
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
|
||||
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
|
||||
public class ApplicationConfig {
|
||||
|
||||
/**
|
||||
* The name of the application.
|
||||
* If not set, defaults to the name of the project.
|
||||
* If not set, defaults to the name of the project (except for tests where it is not set at all).
|
||||
*/
|
||||
@ConfigItem
|
||||
public Optional<String> name;
|
||||
|
||||
/**
|
||||
* The version of the application.
|
||||
* If not set, defaults to the version of the project
|
||||
* If not set, defaults to the version of the project (except for tests where it is not set at all).
|
||||
*/
|
||||
@ConfigItem
|
||||
public Optional<String> version;
|
||||
@@ -490,7 +490,13 @@ public class DevMojo extends AbstractMojo {
|
||||
for (Map.Entry<Object, Object> e : System.getProperties().entrySet()) {
|
||||
devModeContext.getSystemProperties().put(e.getKey().toString(), (String) e.getValue());
|
||||
}
|
||||
|
||||
devModeContext.getBuildSystemProperties().putAll((Map) project.getProperties());
|
||||
|
||||
// this is a minor hack to allow ApplicationConfig to be populated with defaults
|
||||
devModeContext.getBuildSystemProperties().putIfAbsent("quarkus.application.name", project.getArtifactId());
|
||||
devModeContext.getBuildSystemProperties().putIfAbsent("quarkus.application.version", project.getVersion());
|
||||
|
||||
devModeContext.setSourceEncoding(getSourceEncoding());
|
||||
devModeContext.setSourceJavaVersion(source);
|
||||
devModeContext.setTargetJvmVersion(target);
|
||||
|
||||
Reference in New Issue
Block a user