diff --git a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/VariantTransformRegistry.java b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/VariantTransformRegistry.java index 50fcb3e30b9a..061de4570efb 100644 --- a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/VariantTransformRegistry.java +++ b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/VariantTransformRegistry.java @@ -22,6 +22,8 @@ import org.gradle.api.artifacts.transform.TransformSpec; import org.gradle.api.artifacts.transform.VariantTransform; +import java.util.List; + public interface VariantTransformRegistry { /** @@ -33,5 +35,5 @@ public interface VariantTransformRegistry { void registerTransform(Class> actionType, Action> registrationAction); - Iterable getTransforms(); + List getTransforms(); } diff --git a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelector.java b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelector.java index 1f3bde6fc471..9e9a66a01adb 100644 --- a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelector.java +++ b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelector.java @@ -95,8 +95,7 @@ private ResolvedArtifactSet doSelect(ResolvedVariantSet producer) { List> candidates = new ArrayList>(); for (ResolvedVariant variant : producer.getVariants()) { AttributeContainerInternal variantAttributes = variant.getAttributes().asImmutable(); - ConsumerVariantMatchResult matchResult = new ConsumerVariantMatchResult(); - consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, componentRequested, matchResult); + ConsumerVariantMatchResult matchResult = consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, componentRequested); for (ConsumerVariantMatchResult.ConsumerVariant consumerVariant : matchResult.getMatches()) { candidates.add(Pair.of(variant, consumerVariant)); } diff --git a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinder.java b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinder.java index f889a2b72cd4..1cd4de98908f 100644 --- a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinder.java +++ b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinder.java @@ -50,21 +50,20 @@ public ConsumerProvidedVariantFinder(VariantTransformRegistry variantTransforms, this.attributesFactory = attributesFactory; } - public void collectConsumerVariants(AttributeContainerInternal actual, AttributeContainerInternal requested, ConsumerVariantMatchResult result) { + public ConsumerVariantMatchResult collectConsumerVariants(AttributeContainerInternal actual, AttributeContainerInternal requested) { AttributeSpecificCache toCache = getCache(requested); - ConsumerVariantMatchResult cachedResult = toCache.transforms.get(actual); - if (cachedResult == null) { - cachedResult = new ConsumerVariantMatchResult(); - findProducersFor(actual, requested, cachedResult); - toCache.transforms.put(actual, cachedResult); - } - cachedResult.applyTo(result); + return toCache.transforms.computeIfAbsent(actual, attrs -> { + return findProducersFor(actual, requested).asImmutable(); + }); } - private void findProducersFor(AttributeContainerInternal actual, AttributeContainerInternal requested, ConsumerVariantMatchResult result) { + private ConsumerVariantMatchResult findProducersFor(AttributeContainerInternal actual, AttributeContainerInternal requested) { // Prefer direct transformation over indirect transformation List candidates = new ArrayList(); - for (ArtifactTransformRegistration registration : variantTransforms.getTransforms()) { + List transforms = variantTransforms.getTransforms(); + int nbOfTransforms = transforms.size(); + ConsumerVariantMatchResult result = new ConsumerVariantMatchResult(nbOfTransforms * nbOfTransforms); + for (ArtifactTransformRegistration registration : transforms) { if (matchAttributes(registration.getTo(), requested)) { if (matchAttributes(actual, registration.getFrom())) { ImmutableAttributes variantAttributes = attributesFactory.concat(actual.asImmutable(), registration.getTo().asImmutable()); @@ -76,13 +75,12 @@ private void findProducersFor(AttributeContainerInternal actual, AttributeContai } } if (result.hasMatches()) { - return; + return result; } for (ArtifactTransformRegistration candidate : candidates) { - ConsumerVariantMatchResult inputVariants = new ConsumerVariantMatchResult(); AttributeContainerInternal requestedPrevious = computeRequestedAttributes(requested, candidate); - collectConsumerVariants(actual, requestedPrevious, inputVariants); + ConsumerVariantMatchResult inputVariants = collectConsumerVariants(actual, requestedPrevious); if (!inputVariants.hasMatches()) { continue; } @@ -92,6 +90,7 @@ private void findProducersFor(AttributeContainerInternal actual, AttributeContai result.matched(variantAttributes, transformation, inputVariant.depth + 1); } } + return result; } private AttributeContainerInternal computeRequestedAttributes(AttributeContainerInternal result, ArtifactTransformRegistration transform) { diff --git a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerVariantMatchResult.java b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerVariantMatchResult.java index 7a225970b930..e58014fe2159 100644 --- a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerVariantMatchResult.java +++ b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/ConsumerVariantMatchResult.java @@ -16,19 +16,25 @@ package org.gradle.api.internal.artifacts.transform; +import com.google.common.collect.Lists; import org.gradle.api.internal.attributes.AttributeContainerInternal; import org.gradle.api.internal.attributes.ImmutableAttributes; -import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; public class ConsumerVariantMatchResult { private int minDepth; - private final List matches = new ArrayList(); + private final List matches; - public void applyTo(ConsumerVariantMatchResult result) { - result.matches.addAll(this.matches); + ConsumerVariantMatchResult(int estimateSize) { + matches = Lists.newArrayListWithExpectedSize(estimateSize); + } + + private ConsumerVariantMatchResult(ConsumerVariantMatchResult other) { + this.minDepth = other.minDepth; + this.matches = Collections.unmodifiableList(other.matches); } public void matched(ImmutableAttributes output, Transformation transformation, int depth) { @@ -52,6 +58,10 @@ public Collection getMatches() { return matches; } + public ConsumerVariantMatchResult asImmutable() { + return new ConsumerVariantMatchResult(this); + } + public static class ConsumerVariant { final AttributeContainerInternal attributes; final Transformation transformation; diff --git a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/DefaultVariantTransformRegistry.java b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/DefaultVariantTransformRegistry.java index 625dffc61b3b..39302d34c59e 100644 --- a/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/DefaultVariantTransformRegistry.java +++ b/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/DefaultVariantTransformRegistry.java @@ -121,7 +121,7 @@ private static void validateAttributes(RecordingRegistration registration) { } } - public Iterable getTransforms() { + public List getTransforms() { return transforms; } diff --git a/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelectorSpec.groovy b/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelectorSpec.groovy index 3d42c36a43e2..3696ef3b7c42 100644 --- a/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelectorSpec.groovy +++ b/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/AttributeMatchingVariantSelectorSpec.groovy @@ -21,6 +21,7 @@ import org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.Resol import org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariant import org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ResolvedVariantSet import org.gradle.api.internal.attributes.AttributesSchemaInternal +import org.gradle.api.internal.attributes.ImmutableAttributes import org.gradle.api.internal.attributes.ImmutableAttributesFactory import org.gradle.api.internal.tasks.TaskDependencyResolveContext import org.gradle.internal.Describables @@ -137,8 +138,8 @@ class AttributeMatchingVariantSelectorSpec extends Specification { } }) 1 * attributeMatcher.matches(_, _) >> Collections.emptyList() - 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, Mock(Transformation), 1) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, Mock(Transformation), 1) } } @@ -185,11 +186,11 @@ class AttributeMatchingVariantSelectorSpec extends Specification { }) 1 * attributeMatcher.matches(_, _) >> Collections.emptyList() 1 * attributeMatcher.isMatching(requestedAttributes, requestedAttributes) >> true - 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform1, 2) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform1, 2) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform2, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform2, 3) } 1 * attributeMatcher.matches(_, _) >> { args -> args[0] } } @@ -237,11 +238,11 @@ class AttributeMatchingVariantSelectorSpec extends Specification { }) 1 * attributeMatcher.matches(_, _) >> Collections.emptyList() 1 * attributeMatcher.isMatching(requestedAttributes, requestedAttributes) >> true - 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform1, 2) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform1, 2) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform2, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform2, 3) } 1 * attributeMatcher.matches(_, _) >> { args -> args[0] } } @@ -288,11 +289,11 @@ class AttributeMatchingVariantSelectorSpec extends Specification { } }) 1 * attributeMatcher.matches(_, _) >> Collections.emptyList() - 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(otherVariantAttributes, transform1, 2) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes) >> { args -> + match(otherVariantAttributes, transform1, 2) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(variantAttributes, transform2, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes) >> { args -> + match(variantAttributes, transform2, 3) } 1 * attributeMatcher.matches(_, _) >> { args -> [args[0].get(0)] } } @@ -346,14 +347,14 @@ class AttributeMatchingVariantSelectorSpec extends Specification { }) 1 * attributeMatcher.matches(_, _) >> Collections.emptyList() 2 * attributeMatcher.isMatching(requestedAttributes, requestedAttributes) >> true - 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform1, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform1, 3) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform2, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform2, 3) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(yetAnotherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform3, 2) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(yetAnotherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform3, 2) } 1 * attributeMatcher.matches(_, _) >> { args -> args[0] } } @@ -406,14 +407,14 @@ class AttributeMatchingVariantSelectorSpec extends Specification { } }) 1 * attributeMatcher.matches(_, _) >> Collections.emptyList() - 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform1, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform1, 3) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform2, 2) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform2, 2) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(yetAnotherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform3, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(yetAnotherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform3, 3) } 2 * attributeMatcher.isMatching(requestedAttributes, requestedAttributes) >> true 1 * attributeMatcher.matches(_, _) >> { args -> args[0] } @@ -466,16 +467,22 @@ class AttributeMatchingVariantSelectorSpec extends Specification { } }) 1 * attributeMatcher.matches(_, _) >> Collections.emptyList() - 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform1, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(variantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform1, 3) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform2, 2) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(otherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform2, 2) } - 1 * consumerProvidedVariantFinder.collectConsumerVariants(yetAnotherVariantAttributes, requestedAttributes, _) >> { args -> - args[2].matched(requestedAttributes, transform3, 3) + 1 * consumerProvidedVariantFinder.collectConsumerVariants(yetAnotherVariantAttributes, requestedAttributes) >> { args -> + match(requestedAttributes, transform3, 3) } 1 * attributeMatcher.matches(_, _) >> { args -> args[0] } 3 * attributeMatcher.isMatching(requestedAttributes, requestedAttributes) >>> [false, false, true] } + + static ConsumerVariantMatchResult match(ImmutableAttributes output, Transformation trn, int depth) { + def result = new ConsumerVariantMatchResult(2) + result.matched(output, trn, depth) + result + } } diff --git a/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinderTest.groovy b/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinderTest.groovy index f2445927be05..2fa80c70b26f 100644 --- a/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinderTest.groovy +++ b/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/ConsumerProvidedVariantFinderTest.groovy @@ -72,8 +72,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2, reg3] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.size() == 1 @@ -101,8 +100,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2, reg3] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.size() == 2 @@ -130,8 +128,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: def match = result.matches.first() @@ -147,8 +144,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { 0 * matcher._ when: - def result2 = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result2) + def result2 = matchingCache.collectConsumerVariants(source, requested) then: def match2 = result2.matches.first() @@ -172,8 +168,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2, reg3] when: - def matchResult = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, matchResult) + def matchResult = matchingCache.collectConsumerVariants(source, requested) then: def transformer = matchResult.matches.first() @@ -216,8 +211,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2, reg3] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.first().transformation.is(reg3.transformationStep) @@ -256,8 +250,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [registrations[registrationsIndex[0]], registrations[registrationsIndex[1]], registrations[registrationsIndex[2]], registrations[registrationsIndex[3]]] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.size() == 1 @@ -308,8 +301,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2, reg3] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.size() == 1 @@ -342,8 +334,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.empty @@ -366,8 +357,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1, reg2] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.empty @@ -380,8 +370,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { 0 * matcher._ when: - def result2 = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result2) + def result2 = matchingCache.collectConsumerVariants(source, requested) then: result2.matches.empty @@ -406,8 +395,7 @@ class ConsumerProvidedVariantFinderTest extends Specification { transformRegistrations.transforms >> [reg1] when: - def result = new ConsumerVariantMatchResult() - matchingCache.collectConsumerVariants(source, requested, result) + def result = matchingCache.collectConsumerVariants(source, requested) then: result.matches.empty diff --git a/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/DefaultArtifactTransformsTest.groovy b/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/DefaultArtifactTransformsTest.groovy index 357bce597aa4..18a84d23db67 100644 --- a/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/DefaultArtifactTransformsTest.groovy +++ b/subprojects/dependency-management/src/test/groovy/org/gradle/api/internal/artifacts/transform/DefaultArtifactTransformsTest.groovy @@ -151,10 +151,10 @@ class DefaultArtifactTransformsTest extends Specification { consumerSchema.withProducer(producerSchema) >> attributeMatcher attributeMatcher.matches(_, _) >> [] - matchingCache.collectConsumerVariants(typeAttributes("jar"), targetAttributes, _) >> { AttributeContainerInternal from, AttributeContainerInternal to, ConsumerVariantMatchResult result -> - result.matched(to, transformation, 1) + matchingCache.collectConsumerVariants(typeAttributes("jar"), targetAttributes) >> { AttributeContainerInternal from, AttributeContainerInternal to -> + match(to, transformation, 1) } - matchingCache.collectConsumerVariants(typeAttributes("dll"), targetAttributes, _) >> { } + matchingCache.collectConsumerVariants(typeAttributes("dll"), targetAttributes) >> { new ConsumerVariantMatchResult(0) } def result = transforms.variantSelector(targetAttributes, true, dependenciesResolver).select(set) when: @@ -207,8 +207,8 @@ class DefaultArtifactTransformsTest extends Specification { consumerSchema.withProducer(producerSchema) >> attributeMatcher attributeMatcher.matches(_, _) >> [] - matchingCache.collectConsumerVariants(_, _, _) >> { AttributeContainerInternal from, AttributeContainerInternal to, ConsumerVariantMatchResult result -> - result.matched(to, Stub(Transformation), 1) + matchingCache.collectConsumerVariants(_, _) >> { AttributeContainerInternal from, AttributeContainerInternal to -> + match(to, Stub(Transformation), 1) } def selector = transforms.variantSelector(typeAttributes("dll"), true, dependenciesResolver) @@ -247,8 +247,7 @@ Found the following transforms: consumerSchema.withProducer(producerSchema) >> attributeMatcher attributeMatcher.matches(_, _) >> [] - matchingCache.collectConsumerVariants(typeAttributes("dll"), typeAttributes("jar"), _) >> null - matchingCache.collectConsumerVariants(typeAttributes("dll"), typeAttributes("classes"), _) >> null + matchingCache.collectConsumerVariants(_, _) >> new ConsumerVariantMatchResult(0) expect: def result = transforms.variantSelector(typeAttributes("dll"), true, dependenciesResolver).select(set) @@ -273,8 +272,7 @@ Found the following transforms: consumerSchema.withProducer(producerSchema) >> attributeMatcher attributeMatcher.matches(_, _) >> [] - matchingCache.collectConsumerVariants(typeAttributes("dll"), typeAttributes("jar"), _) >> null - matchingCache.collectConsumerVariants(typeAttributes("dll"), typeAttributes("classes"), _) >> null + matchingCache.collectConsumerVariants(_, _) >> new ConsumerVariantMatchResult(0) when: def result = transforms.variantSelector(typeAttributes("dll"), false, dependenciesResolver).select(set) @@ -303,5 +301,11 @@ Found the following transforms: attributeContainer.asImmutable() } + static ConsumerVariantMatchResult match(ImmutableAttributes output, Transformation trn, int depth) { + def result = new ConsumerVariantMatchResult(2) + result.matched(output, trn, depth) + result + } + interface TestArtifact extends ResolvableArtifact, Buildable {} }