I have a java project, which needs to load some files (for spell check) on the disk and these files CAN NOT be packed into jar file.
so I put files under [root]/dict/spellCheck/ folders.
in build.gradle file, i have dependency of the dict folder say:
dependencies {
runtime files(“dict”)
}
and then in java code I have some code to load the file like this:
new File(someClass.getClass().getResource("/spellCheck/index/").toURI());
this works great in eclipse because gradle put the dict in the class path.
the problem comes to the distTar. distTar command creates the tar file includes all jar dependencies and executable script, in the script, it adds “$APP_HOME/lib/dict” folder in the class path, looks good, but, in the lib folder, it does not have the ‘dict’ folder in it, instead it has ‘spellCheck’ folder in it. Now if I run the code, it will no be able to find the ‘spellCheck’ folder because it’s not in the classpath. If I manually create lib/dict/ folder, and move the spellCheck into dict folder, then very thing works fine. But I couldn’t let my customer to do that every single time.
The problem seems to like this: distTar task think the runtime files(“dict”) is a FileCollection object, so it iterate it, copy all sub folders in it to the lib folder, which in this case is wrong, I suppose it should copy the dict folder it self.
Am I doing anything wrong? Is there different way to write build.gradle file for this issue?