Hi,
I have an external program which I’m running from my gradle script. The program depends on a properties for it to work. I’m trying to load that same properties file in my gradle script. Can this be done? It might be easier to visualize the scenario. Here’s my directory structure:
MyProjectDir > build.gradle >lib >>extProgram.jar >>extProgram.properties
As you can see, the extProgram.properties is required by extProgram.jar, both of which are in the “lib” directory. I need to access some property value that is already defined in the extProgram.properties file and use it in my build script tasks.
I added the following line at the beginning of my build.gradle file:
apply from: 'lib/extProgram.properties'
When I run my build script, it complains about the very first line of the properties file because it starts with “##”. Those are used for comments. Even if I remove all the comments from the properties file, the build script is still not able to load/read the properties.
If I copy the extProgram.properties to the root of my project directory and rename that to “gradle.properties”, everything seems to be fine. It’s able to read the properties. Verified it by printing a property value to the client.
So, I guess my question is how can I load the same properties into my script without maintaining two separate properties file. I thought of reading and parsing the properties file, but that doesn’t sound efficient. I think there’s an alternative, but I can’t seem to find it anywhere so far.
I went through the following documentation on properties file in gradle but unless I missed it somehow, I couldn’t find anything related to what I’m doing.
https://gradle.org/docs/current/userguide/tutorial_this_and_that.html
Thanks,