How to publish with classifier to maven repo

I am using the maven-publish and want to publish multiple artifacts with various classifier

http://www.gradle.org/docs/current/dsl/org.gradle.api.publish.maven.MavenPublication.html

According to the guideline, i use the following method to mention the classifier for javadoc and aar.

publishing {
    publications {
        maven(MavenPublication) {
            artifact source: file("${project.buildDir}/outputs/aar/${project.name}-${project.version}.aar"),classifier:"aar",extension:"aar"
        }
        maven(MavenPublication) {
            artifact source: file("${project.buildDir}/docs/javadoc.zip"), classifier:"javadoc", extension:"zip"
        }
    }
}

Two files are uploaded properly.

However, the pom.xml is something like this. It seems the classifier is not properly set. Any ideas on how to set classifier ?

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.abc.android</groupId>
  <artifactId>lib</artifactId>
  <version>2.3.0</version>
  <packaging>pom</packaging>
</project>

In the usual case, one of the artifacts is published without a classifier, and the pom does not define a classifier. Where no artifacts are published without a classifier, Gradle would need to guess which artifact was the ‘primary’ artifact and include that in the pom. Gradle doesn’t do this (yet).

You’ll need to use MavenPom.withXml to insert the classifier you require.