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.

  1. All data files should go into the directories present in src/main/resources or src/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.
  2. 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 in src/main/resources folder.
  3. As an example, if DictionaryMatcher is using a file dictionary.txt, then the file should be put in src/main/resources/dictionatyMatcher folder. If DictionaryMatcherTest is reading some sample data from dmTest.txt, then that file should go to src/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.