How do I put resources in to a separate directory in build


(Chad Cordero) #1

When I do a gradle build and extract the tar file I get the following

project-1.0/
project-1.0/lib/
project-1.0/lib/project-1.0.jar

project-1.0/bin/
project-1.0/bin/project
project-1.0/bin/project.bat

I have a key file that I put in the resources directory, but It can’t see the file when I extract and run the application after it is built. How do I put resources in to its own directory like below and have it run properly?

project-1.0/
project-1.0/lib/
project-1.0/lib/project-1.0.jar

project-1.0/res/Keys/myKey.p12
project-1.0/bin/
project-1.0/bin/project
project-1.0/bin/project.bat


(Carlo Luib-Finetti) #2

did you put the file into ‘./src/main/resources/Keys’? Then it should go automatically into the jar. But if have your own directory ‘res’, than you can do something like this:

into (’/res/Keys’) {
from new File(’./res/Keys’)
}

or, define sourceSets like this:

sourceSets {
main {
resources {
srcDir ‘res’
}
}
}

Have a look into the user manual, “45.4.1. Changing the project layout”.