Use ResolutionStrategy for project dependencies?

Is it possible to use something like ResolutionStrategy for project dependencies? The docs seem focused on remote dependencies (the example used is "How to override a version).

I’m writing a plugin that specifies a custom configuration. I’d like to modify how those project dependencies are resolved to task dependencies.

Simplified Usecase: I’d like the use to be able to specify

pluginConfig project(":myProject")

and say, have it resolve as:

pluginConfig project(path: ":myProject", configuration: 'pluginConfig')

More Complex Usecase: I’d like to be able to do:

pluginConfig project(":myProject")

and say, have it resolve as:

pluginConfigA project(path: ":myProject", configuration: 'pluginConfigA')
pluginConfigB project(path: ":myProject", configuration: 'pluginConfigB')

I know the user having to specify a configuration is only a minor annoyance, but them having to specify two (for both the outputs of my plugin) is a more serious problem, because I have to handle (or leave undefined) the usecases where the user add’s one and not the other. Also, because it is something that should be able to be automated away :P.

I’m currently looking at providing a marco that the user can call (a closure the user can call that sets up the dependency for them), but since I’m defining this configuration, seems I should be able to customize it’s resolution instead.

At the moment, dependency-substitution rules are only applicable to external dependencies. We are about to start work on improving this to apply to project dependencies as well, allowing substitution of project for external dependencies (and vice-versa). The design spec is here:

Awesome Daz! It looks like the proposed design would not only allow you to swap out project for external dependencies, but swap out project dependencies for other project dependencies, which was basically what I wanted to do.

As someone who tried to set up a system that we wanted some projects to be buildable either independently or as part of a larger build, I have to say the current options (best of which I saw was using the maven local repository for multiple builds) feel very hacky and this would be much better :slight_smile:

If anyone wants to know what my current work around is, it is setting a closure variable in the plugin:

project.ext.pluginProject = {String projectName ->...}

And then used pluginProject in the place of project(). Workable, if not ideal.