How to publish JAR with test fixtures in Gradle?

The right way to do this would be to use classifier “tests”, but Gradle ignores classifiers: https://issues.gradle.org/browse/GRADLE-2381.
So, I specified JAR name explicitly:

// Create JAR with test fixtures
task testJar(type: Jar, dependsOn: testClasses) {
    baseName = "${project.archivesBaseName}-tests"
    from sourceSets.test.output
}

artifacts {
    archives testJar
}

tasks.uploadArchives.dependsOn testJar

Problem: Gradle is trying to publish mymodule-tests.jar using the same name as the main JAR:

A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact mymodule:jar:jar:null, trying to add MavenArtifact mymodule:jar:jar:null.

Have you tried the following?

task testJar(type: Jar, dependsOn: testClasses) {
   classifier = 'tests'
    from sourceSets.test.output
}

Yes. Gradle ignores classifiers: https://issues.gradle.org/browse/GRADLE-2381.

That’s a WTF moment for me as I am using classifiers to create source and javadoc jars which are published to Bintray which are then published. This had me confiused until I realised the issue is not the creation of the JAR, but the actual listing inside the POM.

It looks like a bug to me indeed.

Was this ever resolved. The owner of the Gradle issue closed it this February with a “WONT FIX” but I don’t see a good work-around for publishing multiple artifacts from a build. Is there one?