0

I am working on a Java project that contains many properties files and the structure looks like this:

src
   |
    -main
        |
         -java
             |
              -ui
                |
                 -many directories with property file in each directory.

I want to build fat jar using Gradle build that will contain those files in the same directories.

Something like:

build
   |
    -classes
        |
         -java
             |
              -main
                |
                 -ui.... and all the files like above.

How can I to do it?

1 Answers1

0

By convention gradle will package all the properties (and other resource) files placed under src/main/resources into the final jar artifact.

If you are sure that you still want to place your properties file under src/main/java then you can configure resources source sets location using the following snippet in your build.gradle

sourceSets {
  main {
    resources { 
      srcDirs = ["src/main/java"]
      include "**/*.properties"
    }
  }
}

The properties files will not end up in build/classes but will be part of you jar. You you want them to be build/classes/java as well (not recommended), then you need to configure the output dir for resources as well. See this answer.

kdabir
  • 9,623
  • 3
  • 43
  • 45