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'])
}
}
compileJava — JavaCompile. Depends on: All tasks which contribute to the compilation classpath, including jar tasks from projects that are on the classpath via project dependencies. Compiles production Java source files using the JDK compiler. processResources — ProcessResources.
main. runtimeClasspath' contains the compiled classes of the source set, and task autowiring automatically adds the necessary task dependencies. Maybe you want 'sourceSets. main. compileClasspath'.
According to Gradle documentation: sourceCompatibility is "Java version compatibility to use when compiling Java source." targetCompatibility is "Java version to generate classes for."
An annotation processor is a class which extends AbstractProcessor (in the package javax. annotation. processing ) providing the functionality needed to generate whatever it needs to generate, such as classes in the case of mapstruct.
Just add the required files to the default processResources task:
processResources {
from ('src/main/java') {
include '**/*.properties'
include '**/*.csv'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With