Use a custom properties file

Mike Rylander picture Mike Rylander · Jun 28, 2013 · Viewed 8.5k times · Source

I would like to have a properties file that deployed with my application so that I can access it at runtime. How can I have my build.gradle file access my property file located in src/main/resources?

I would like to use this file as I would normal use gradle.properties.

Answer

Rene Groeschke picture Rene Groeschke · Jun 28, 2013

You want to read this properties file in your build.gradle file? You can simply:

def props = new Properties()
file("src/main/resources/my.properties").withInputStream { 
    stream -> props.load(stream) 
}