I have a multimodule web project with a dependency graph similar to this
WAR-project
- A1
-- A2
-- A3
- B1
-- B2
---- B22
-- B3
that is the war project depends on A1 which in turn depends on A2 and A3 and so on.
Now prior to the packageing of the war project I want to copy some web resources from its dependent projects into the webapp. So my question is how do I programmatically traverse a SBT project's dependency graph ? i.e. in pseudu code
resourcesToCopy = []
visitedProjects = []
traverseProjectDependencies(project) {
visitedProjects += project
if(project has resourceFolder) {
resourcesToCopy += resourceFolder.getPath
}
for(projectDependency in project) {
if(projectDependency is not visited) {
traverseProjectDependencies(projectDependency)
}
}
}
Note I am aware that if I add the resource folder to the classpath of each of the dependencies then I could retrieve it from the fullClasspath in the web project. But I would like to avoid this solution and also there are other scenarios where programmatically traversing and interfacing with dependencies could be useful.