How to exclude a dependency of a project dependency in a multiproject

With a module dependency, I can do this:

compile ("org.apache.velocity:velocity-tools:2.0") {
        exclude group: 'xml-apis',
module: 'xml-apis'
    }

but trying a similar thing with a project dependency in a multiproject like this:

compile project(':sod') {
        exclude group: 'org.python',
module: 'jython-standalone'
    }

I get this:

* What went wrong:
A problem occurred evaluating project ':gee'.
> Could not find method exclude() for arguments [{group=org.python, module=jython-standalone}] on project ':sod'.

Is there a way to exclude a transitive dependency of a project dependency?

thanks Philip

Figured out that I can do this on the configurations even if it doesn’t work on a per dependency basis with

configurations {
    all*.exclude
group: 'org.python',
module: 'jython-standalone'
}

Philip