gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.67k stars 4.66k forks source link

generateMetadataFileForJavaLibraryPublication task fails with Invalid publication 'javaLibrary' #11700

Closed koral-- closed 4 years ago

koral-- commented 4 years ago

Expected Behavior

Task generateMetadataFileForJavaLibraryPublication should succeed.

Current Behavior

Task generateMetadataFileForJavaLibraryPublication fails with

[performRelease] > Invalid publication 'javaLibrary':
[performRelease]     - Variant 'releaseArchives' must declare at least one attribute.

Context

Which version did this stop working with? 6.0.1

Which version do you know it works? 5.6.2

What are you trying to accomplish? I'm trying to use shipkit to publish AAR release.

Steps to Reproduce

Invoke ciPerformRelease task on https://github.com/DroidsOnRoids/FoQA/ project. Failing commit: https://github.com/DroidsOnRoids/FoQA/commit/efc59bf3ad0c078e75e2c40495c2c1434c11a52c Successful commit: https://github.com/DroidsOnRoids/FoQA/commit/b5e1b4a394f9b3c538c46345e2da3e9d4e76a0b5

Your Environment

Failed Build scan URL: https://gradle.com/s/mwnyb453o2qkw Successful Build scan URL: https://gradle.com/s/4xskh3bpqb23k

jjohannes commented 4 years ago

@koral-- I don't think this is a regression in that sense. Gradle 6 publishes all information from the Java component (components.java) which the shipkit plugin uses for the publication. This is possible because Gradle now publishes Gradle Module Metadata. Before, some information was just discarded.

So you now get the error because there is incomplete information.

I can't get to the root of the problem, because I can not reproduce it. What you indicate in the description requires to run a real publishing.

A workaround (probably not the "right" solution) could be to skip publishing for releaseArchives (but I don't know what that represents).

components.java.withVariantsFromConfiguration(configurations.releaseArchives) {
    skip()
}

See also: https://docs.gradle.org/current/userguide/publishing_customization.html#sec:adding-variants-to-existing-components

If you can provide a reproducible example I can run, I can maybe provide more guidance.

koral-- commented 4 years ago

I think that the easiest way of creating reproducible sample is to fork sample project repo: https://github.com/mockito/shipkit-android-example and add appropriate tokens: https://github.com/mockito/shipkit-android-example/blob/master/gradle/shipkit.gradle

You can ignore bintray part.

jjohannes commented 4 years ago

Hi @koral-- thanks. The problem is that this setup in com.github.technoir42.aar-publish is not sufficient for Gradle 6 and a proper publishing of Android variants: https://github.com/technoir42/aar-publish-plugin/blame/2a3da935c9d1a618d0a784d1e04f32fb3adab3e2/plugin/src/main/kotlin/com/github/technoir42/plugin/aarpublish/AarPublishPlugin.kt#L41-L44

With Android 3.6.0 (beta05+) and 4.0.0 publishing is supported by the Android plugins directly and the components are setup in the right way there. You should use that directly by using one of the following components in the publication you setup in "org.shipkit.android-publish":

koral-- commented 4 years ago

Thanks for the the research. I'll try to update shipkit then and close this issue after confirmation that it works.