I am trying to move a simple Groovy project to Gradle. I was mostly able to configure the project, but I do not know how to deal with external resources.
Basically, my application needs to access a configuration file in JSON. Before moving to Gradle, I used to pass the location of this JSON file on the command line. I had made a simple bash script to call the main class with the correct path for the resource.
With Gradle if I understand correctly, I should be able to move this file into src/main/resources/ and have it available somehow from the Groovy classes. Question is: how?
EDIT
If I understand correctly, the resource should end in the JAR that gets built. My dir structure is like
src
main
groovy
orgName
packageName
source.groovy
resources
orgName
packageName
config.json
But I do not see the resource inside the packageName.jar that is generated in the build directory
I knocked up a quick example… Given this directory structure:
Where
Test.groovyis:config.jsonis:and
build.gradleis:You should just be able to run
gradle runTestand it should just work…