I have two projects:
- Main: M
- Dependency: D
Project D has a subdirectory called 'xsd' where it has a few XSD files that it uses for validation.
This is the piece of code in project D that retrieves these XSD files:
private List<StreamSource> retrieveSchemaDefinitionsFromClasspath(String classpathXsdDir, String schemaDefinitionFilePattern) {
ClasspathResourceManager resourceManager = new ClasspathResourceManager()
List<String> schemaDefinitionFileNames = resourceManager.getReader(classpathXsdDir).text.split()
schemaDefinitionFileNames.findAll { it ==~ schemaDefinitionFilePattern }.collect {
new StreamSource(resourceManager.getReader("$classpathXsdDir/$it"))
}
}
Now, this piece of code works well when I run my test cases.
However, when I use project D as a dependency inside project M, I get a NullPointerException on this line of the above method:
List<String> schemaDefinitionFileNames = resourceManager.getReader(classpathXsdDir).text.split()
I've looked at this answer: Load jar file contained within another jar file not working which points to the JarClassLoader turorial: http://docs.oracle.com/javase/tutorial/deployment/jar/jarclassloader.html
However, from what I could gather from the JarClassLoader tutorial, it looks like I need to specify the name of the jar.
But, I want to be able to seamlessly use the dependency jar produced by project D in any project without having to worry about what project/jar D does to load it's reasources.
So, what is the best way to approach this problem?
Thanks!