Complex dependency resolution with Maven and possibly Aether - how?
I'm trying to write a Maven plugin which does the following: Get all dependencies of a module and find out whether any transitive dependeny of it has a transitive dependency to any sibling module of the current module.
My idea is the following:
- Get the module's parent (POM-only parent) and then get all of its modules, to find the siblings of the current module.
- Get the module's transitive dependencies (but only for our group ID).
- For each of the transitive dependencies, get its transitive dependencies and find out whether any of them is one of the sibling modules.
I've tried doing it in Maven 2 style and now ended with Aether. However, I'm not sure whether it's possible to do what I want with Aether.
Currently, I can get the POM-only parent (not with Aether, but with the MavenProject) and I can get the transitive dependencies and then filter them to keep only artifacts with our group ID. I didn't find the equivalent of the Maven FilterArtifacts in Aether.
So, the questions are: Is my idea of how I can accomplish my goal correct? Can I do that with Aether only? If yes, how do I do it? Or do I have to resort to a mix of Maven 2 and Aether? (I tried a bit, but the differences between the SNAPSHOT version and the timestamp SNAPSHOT version are a bit cumbersome)
Anyway, any help is greatly appreciated!
You can use jcabi-aether library (I'm one of developers), which can help you to do what you want:
- Get a list of modules from MavenProject
- Get their dependencies
- Loop through them one by one and resolve them using com.jcabi.aether.Aether
Should work fine with Maven 3