Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test for #9882 #9883

Merged
merged 4 commits into from Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1089,4 +1089,58 @@ class AlignmentIntegrationTest extends AbstractAlignmentSpec {
virtualConfiguration("org:platform:1.1")
}
}

@RequiredFeatures([
// We only need to test one flavor
@RequiredFeature(feature = GradleMetadataResolveRunner.GRADLE_METADATA, value = "true"),
@RequiredFeature(feature = GradleMetadataResolveRunner.REPOSITORY_TYPE, value = "maven")
])
def "should manage to realign through two conflicts"() {
repository {
path 'start:start:1.0 -> foo:1.0'

path 'foo:1.0 -> bar:1.0'
path 'foo:1.1 -> bar:1.1'

'org:bar:1.0'()
'org:bar:1.1'()
}

given:
buildFile << '''
dependencies {
constraints {
conf platform("org:platform:1.1")
}

conf 'start:start:1.0'
}
'''

and:
"align the 'org' group only"()

when:
expectAlignment {
module('start') group('start') alignsTo('1.0')
module('foo') tries('1.0') alignsTo('1.1') byVirtualPlatform()
module('bar') tries('1.0') alignsTo('1.1') byVirtualPlatform()
}
run ':checkDeps', 'dependencyInsight', '--configuration', 'conf', '--dependency', 'bar'

then:
resolve.expectGraph {
root(":", ":test:") {
module("start:start:1.0") {
edge("org:foo:1.0", "org:foo:1.1") {
byConstraint("belongs to platform org:platform:1.1")
module("org:bar:1.1") {
byConstraint("belongs to platform org:platform:1.1")
}
}
}
}
virtualConfiguration("org:platform:1.1")
}
}
}
Expand Up @@ -68,7 +68,7 @@ private boolean markNoLongerPending(PendingDependencies pendingDependencies) {
noLongerPending = Lists.newLinkedList();
}
noLongerPending.add(pendingDependencies);
activatedPending = true;
activatedPending = pendingDependencies.shouldReportActivatePending();
}
pendingDependencies.increaseHardEdgeCount();
return activatedPending;
Expand Down
Expand Up @@ -24,11 +24,13 @@ public class PendingDependencies {
private final ModuleIdentifier moduleIdentifier;
private final Set<NodeState> affectedComponents;
private int hardEdges;
private boolean reportActivePending;

PendingDependencies(ModuleIdentifier moduleIdentifier) {
this.moduleIdentifier = moduleIdentifier;
this.affectedComponents = Sets.newLinkedHashSet();
this.hardEdges = 0;
this.reportActivePending = true;
}

ModuleIdentifier getModuleIdentifier() {
Expand All @@ -40,13 +42,17 @@ void addNode(NodeState state) {
throw new IllegalStateException("Cannot add a pending node for a dependency which is not pending");
}
affectedComponents.add(state);
if (state.getComponent().getModule().isVirtualPlatform()) {
reportActivePending = false;
}
}

void turnIntoHardDependencies() {
for (NodeState affectedComponent : affectedComponents) {
affectedComponent.prepareForConstraintNoLongerPending(moduleIdentifier);
}
affectedComponents.clear();
reportActivePending = true;
}

public boolean isPending() {
Expand All @@ -65,4 +71,8 @@ void decreaseHardEdgeCount() {
assert hardEdges > 0 : "Cannot remove a hard edge when none recorded";
hardEdges--;
}

public boolean shouldReportActivatePending() {
return reportActivePending;
}
}