Given the following pom the dependency tree looks like this
You expect the entire tree to have the optional flag set to true. But sadly that's not the case. com.google.guava:guava and com.google.code.findbugs:jsr305 are optional = false.
I found that this is because they are managed dependencies (no difference whether imported or declared directly). When I use this pom it works.
There are some integration tests in this repository that demonstrate the issue. Checkout demonstrate-tree-bug branch and run "mvn verify". Now compare these files in target/it
Let me know if I can help you reproduce the problem.