Hey folks. I have a question loosely related to ho...
# plugin-development
k
Hey folks. I have a question loosely related to how things work with the Kotlin Multiplatform Plugin: I currently have this code:
Copy code
val testResultsElements = configurations.consumable("testResultsElementsForJvmTest") {
    // This configuration mimics that defined by the "test-suite-base" plugin
    description = "Binary results obtained from running the 'jvmTest' suites."

    attributes.attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.VERIFICATION))
    attributes.attribute(VerificationType.VERIFICATION_TYPE_ATTRIBUTE, objects.named(VerificationType.TEST_RESULTS))
    // FIXME how do we accommodate multiple JVM targets and their respective test suites?
    attributes.attribute(TestSuiteName.TEST_SUITE_NAME_ATTRIBUTE, objects.named("test"))

    val binaryDir = tasks.named<Test>("jvmTest").flatMap { it.binaryResultsDirectory }
    outgoing.artifact(binaryDir) {
        type = ArtifactTypeDefinition.DIRECTORY_TYPE
    }
}
I'm wondering what I would have to change if I had two source sets that produced JVM code, so I would have two "testResults" configurations. And how that would relate to the test result aggregation plugin since I would need to differentiate them in such a way that the aggregation plugin could pick each of them separately.
v
The test suite name attribute is what you use to choose
k
Odd. When I tried to add a dependency in the project that uses the aggregation plugin, it only accepted
test
. Perhaps I'm doing something wrong.
v
What do you mean with "it only accepted `test`"? What happened?
k
I got a
Mutation of attributes is not allowed
error when I try
Copy code
dependencies {
  testReportAggregation(...) {
    attributes.attribute(TestSuiteName.TEST_SUITE_NAME_ATTRIBUTE, objects.named("jvmTest"))
  }
}
Not sure if I'm doing that correctly.
v
No, you only set the attribute on the producer. For consumption you do it like documented in the user guide
k
Copy code
org.gradle.internal.component.resolution.failure.exception.VariantSelectionByAttributesException: The consumer was configured to find a component of category 'verification', as well as attribute 'org.gradle.testsuite.name' with value 'test', attribute 'org.gradle.verificationtype' with value 'test-results'
This is what I get when I have it as
jvmTest
in my producer. The error reads as if it accepts
test
and nothing else.
v
It accepts what you request
Look at the docs of the aggregation plugin
k
Right, but I need to aggregate reports for which it is
test
in some and
jvmTest
in others.
Hopefully without doing some trickery to "rename" one to the other.
v
Nope
You can only aggregate over the same test suite name
You don't need to rename, you could also add the same artifacts to multiple outgoing variants with different test suite names
But everything you want to aggregate (no matter whether jacoco aggregation or test report aggregation) needs to have the same test suite name in all aggregated projects
I for example add all jacoco results of all test suites in a project to an
all
outgoing configuration and can then do an aggregated jacoco report over all test suites
k
Oof. Smoke and mirrors with configurations it is, I suppose. That's kind of a "rename".
v
Nah, it's a copy or alias 😄