Q:

How can I upload all the flavor apks to nexus using gradle?

So I've been successfully using the uploadArchives task to upload aar libraries to Nexus.
I want to do the same thing now with apks but not really managing to get it right at the moment.
I'm pretty much doing the same thing but with different packaging. That doesn't do the trick though.
I'm wondering now if using the uploadArchives task is really the way of doing this or if I should use a different task.
Here's the code that I'm using now and that let's me upload aar libraries:
uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: getPropertyValue('mUrl')+"/content/repositories/releases/") {
                authentication(userName: getPropertyValue('mUserName'), password: getPropertyValue('mPassword'))
            }

            def version = getPropertyValue('version')
            _productFlavors.each { name, config ->
                def releaseName = name+"Release"
                addFilter(releaseName) { artifact, file ->
                    artifact.attributes.classifier.equals(releaseName)
                }
                pom(releaseName).artifactId = "artifact"
                pom(releaseName).version = version
                pom(releaseName).groupId = "com.example."+name
                pom(releaseName).packaging = "apk"
            }
        }
    }
}

A:

A little bit late but I managed to get this working using the old plain httpclient.
def uploadToRepository(File file, String folder, String url, String userName, String password){
if(url != null && !url.isEmpty()){
    def client = new DefaultHttpClient()
    def post = new HttpPost("${url}/content/repositories/releases/${folder}/myapk.apk");
    def entity = new MultipartEntity()
    def fileBody = new FileBody(file, "application/vnd.android.package-archive", file.name)
    entity.addPart("file", fileBody)
    post.entity = entity

    def basicAuthString = "Basic " + "${userName}:${password}".bytes.encodeBase64().toString()
    post.addHeader('Authorization', basicAuthString);

    post.setEntity(entity);
    def response = client.execute(post);
    if(response.getStatusLine().getStatusCode() == 201)
        println "${file.name} uploaded"
}
}

uploadArchives {
    repositories {
        mavenDeployer {
            def version = getPropertyValue('version')
            def buildVersion = ''

            _productFlavors.each { name, config ->
                def releaseName = name+"Release"
                addFilter(releaseName) { artifact, file ->
                    artifact.attributes.classifier.equals(releaseName)
                }
                def fileName = "${project.buildDir}\\outputs\\apk\\something.app-${name}-release.apk"
                def file = new File(fileName)
                uploadToRepository(
                        file,
                        "com/something/${name.replaceAll('_','/')}/something/${version+buildVersion}/",
                        getPropertyValue('mUrl'),
                        getPropertyValue('mUserName'),
                        getPropertyValue('mPassword')
                )
            }
        }
    }
}

