Home > database >  how can I inject gradle ext properties
how can I inject gradle ext properties

Time:12-05

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?

CodePudding user response:

The following worked for me:

@ConfigProperty(name = "buildTime", defaultValue="defaultValue")
String buildTime;

CodePudding user response:

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

  • Related