Open lptr opened 9 years ago
Yes, I think that was the intent of Adam when he suggested the 'observed' state.
Observed - The configuration has been used in a resolution, and it is deprecated for build logic to change any dependencies, artefacts, exclude rules or parent configurations. Changes are ignored by the consuming configuration. This is currently implemented using the
DefaultConfiguration.includedInResult
flag. This state should also be used the configuration is used via a project dependency, but currently it is not.
I see. Makes total sense. That's not what we have in master, though, as currently DefaultConfiguration.resolveNow()
is responsible for marking configurations as observed. I'll change this.
Didn't manage to find a way yet to mark a project dependency's configuration as observed, but moved marking configurations as observed to DefaultConfigurationResolver
in this: ea7d944891af570f5fc660eb23adc7b177d0321a
Marking configurations observed must happen in parent->child order. I fixed that for configurations that extend each other.
I've also found a way to mark project dependency configurations as observed, but they happen after the originating configuration has been observed. This brings up a problem, where a configuration depends on another project's configuration that has a beforeObserve() rule that adds a dependency.
Added a test case for that in 9bdc69f56494dec2f9ac119fd4688d9e3cb0e7cf
Perhaps we can find a way to mark the project configuration as observed while the originating configuration is resolving? So when we traverse the project dependency to build out the graph, we mark the project configuration as observed before getting the project artifacts/dependencies. This would allow 'beforeObserved' to work as expected?
I'm suggesting this without considering how this would work in code.
@bigdaz:
I haven't looked, but your comment suggests that you mark the dependency configuration as 'observed' after the referencing configuration has completed resolving. This prevents 'beforeObserved' from working in this case (or 'beforeResolved' if we change it's semantic).
Perhaps we can find a way to mark the project configuration as observed while the originating configuration is resolving? So when we traverse the project dependency to build out the graph, we mark the project configuration as observed before getting the project artifacts/dependencies. This would allow 'beforeObserved' to work as expected?
Yes, that would help indeed, only I couldn't figure it out yet how to do this in the current dependency graph resolution. Let's talk about this.
You'd change the state in ProjectDependencyResolver
.
I guess we can do that, but we need to make a decision about how to go about default dependencies here: https://github.com/prezi/gradle/issues/17#issuecomment-80689313
When a configuration resolves a project dependency, I think the configuration referenced in that dependency should also be marked as
OBSERVED
. Shall we do this? I guess the best place for this isProjectDependencyResolver.resolve()
.