Reputation: 121
I have some .properties files along with .java files in the java project. When Gradle compiles it seems to be only taking .class file and ignoring the .properties files & .csv files while making the jar.
Can anyone let us know how to get the .properties files, .csv files also gets compiled into the classes folder?
For example, if my project has the following files,
"src/main/java/com/spcapitaliq/test/Test.java"
"src/main/java/com/spcapitaliq/test/Test.properties"
"src/main/java/com/spcapitaliq/test/Test.csv"
I am seeing only the Test.class in the classes folder not the Test.properties & Test.csv files. Can you let me know how to include the .properties files & .csv files during the gradle compilation process. In eclipse, its bringing both but gradle compile is ignoring that.
The following is my SourceSet entry in "gradle.build" file,
sourceSets
{
main
{
java
{
srcDir 'src/main/java’
}
resources
{
srcDir 'src/main/resources'compileClasspath = configurations.runtime + fileTree(dir:"$project.HOME_DIR/$project.SERVICE_NAME/lib", includes: ['*.jar'])
}
}
Upvotes: 12
Views: 3899
Reputation: 2836
Just add the required files to the default processResources task:
processResources {
from ('src/main/java') {
include '**/*.properties'
include '**/*.csv'
}
}
Upvotes: 14