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

May be helpful:

configuration.getIncoming().getResolutionResult().getAllDependencies().forEach( dependencyResult -> {
    if( dependencyResult instanceof ResolvedDependencyResult ) {
        ResolvedDependencyResult resolved = (ResolvedDependencyResult)dependencyResult;
        boolean isProj = resolved.getSelected().getId() instanceof ProjectComponentIdentifier;
        project.getLogger().lifecycle( "{} is project: {}", dependencyResult.getRequested(), isProj );
    }
} );