Right way to custom-resolve dependencies

In my build script I need to specify dependency in the following way

dependencies {
resource project(‘p1’), path: "some/resource1"
resource project(‘p2’), path: “some/resource2”
}

during processing build script should take output artifact of source project and extract given resource from there.

The problem I see is - gradle DSL does not seem to allow definition of dependencies having additional arguments, so that I can extract these additional attributes from dependency definition. I can implement own DSL to define dependencies, but i can’t find the way to resolves then.

What API should be used for that? E.g: i have ‘project-id’ and i want target project to be compiled (if needed) and then get its artifact files (jar) to extract needed resource.