Documentation for MavenPublication uses wrong classifier for sources

The default classifier for a sources jar in maven is ‘sources’, and all tools I know use the same string to download source jars, and will probably fail if the source is uploaded with any other classifier.

Yet the main example on MavenPublication within the Gradle 2.2 documentation, which shows how to attach a source jar, is using a different classifier. Everyone who copy’n pasted this snippet is now uploading their source incorrectly.

There are more examples within the methods description which use yet another classifier, and incorrectly show how to configure an artifact, because this code snippet

artifact sourceJar {
    // These values will be used instead of the values from the task. The task values will not be updated.
    classifier "src"
    extension "zip"

is configuring the task, not the artifact, as the closure is called on ‘sourceJar’ not passed in as argument to the method due to missing parenthesis. It works, but the example is wrong, and it does update the task values.

Thanks for reporting. Some snippets in that file have indeed syntax errors and will configure the wrong thing. This will be fixed.

Wherever ‘src’ is used as a classifier in snippets for ‘MavenPublication’ it is done to show that you can overwrite the classifier specified on the task from the publication level. The main example (in class description) shows using ‘source’ as a classifier for the artifact produced by ‘sourceJar’. I believe that you should pay at least some attention when copy-pasting code and people should be able to spot the difference.

… but ‘source’ is also wrong … it should be ‘sources’.

Right, thanks for pointing this out. I changed it here: