I am trying to pass project version and compilation time to my Quarkus project via build.gradle and GradleExtraProperties.
I have in my gradle.build file:
version '0.0.0-SNAPSHOT'
ext {
buildTime = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date())
}
and in my Java source:
@ConfigProperty(name = "version")
String version;
@ConfigProperty(name="buildTime")
String buildTime;
While version gets properly injected, buildTime fails with
ConfigurationException: Failed to load config value of type class java.lang.String for: buildTime
Does anybody know if and how that can be accomplished?
The following worked for me:
@ConfigProperty(name = "buildTime", defaultValue="defaultValue")
String buildTime;
The answer was simple and much more embarrassing: If one runs Quarkus in dev mode, Gradle does not build the project. After I run gradew build
everything was just fine. SMH
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.