Getting substituted dependencies

I have a plugin that looks for project dependencies in a given configuration using :

configuration.getResolvedConfiguration().getResolvedArtifacts()

This return all configuration dependencies but not substituted dependencies. It tried using :

configuration.getIncoming().getResolutionResult().getAllDependencies();

But I’m unable to clearly identify substituted dependencies, how can I use this API ?

The goal is to be able to detect something like : ./gradlew --include-build ../lib clean build