Guidelines for Organizing Data Files - Texera/texera GitHub Wiki
Authors(s): Kishore Narendran, Shiladitya Sen
Here are some guidelines on where to put data files.
- All data files should go into the directories present in
src/main/resources
orsrc/test/resources
. Please create them if they are not already present. By default these folders are made into source folders when maven build happens. Please create the directories inside these source folders so that the files are organized properly. - If the data files are used by the test classes, put them in
src/test/resources
folder. If the data files are used by the main classes, put them insrc/main/resources
folder. - As an example, if
DictionaryMatcher
is using a filedictionary.txt
, then the file should be put insrc/main/resources/dictionatyMatcher
folder. IfDictionaryMatcherTest
is reading some sample data fromdmTest.txt
, then that file should go tosrc/test/resources/dictionaryMatcher
folder.
Notice that maven doesn't preserve the structure of src/main/resources
or src/main/java
when it packages the files into jar or war. So it is important not to use the path "src/main/resources" while opening the files. The relative path should start from the classpath. We can use the methods getResource()
or getResourceAsStream()
present in java.util.Class
for reading the files.