Publish to Amazon S3

I found a reference here

to a Gradle task that publishes to Amazon S3, but the link is broken:

Does this task def still exist somewhere?

It’s no longer part of the Gradle build, but you could still grab it from the Git repository.

So to write a Gradle plugin to publish maven artifacts to an S3 bucket, how would one proceed?

Seems like the plugin would extend the maven-publish plugin in some way, then it would need file system references to all the maven artifact files for snapshot and release artifacts so it could write them to the S3 bucket. Writing to the S3 bucket is easy. Getting references to the files to upload is not so obvious.

Can anyone offer some guidance on how to approach this?


I’ve read enough of the MavenPublishPlugin to tentatively conclude that pushing to S3 repositories would involve selecting a Maven S3 wagon, such as is implemented here

Do I have that about right?

I don’t know how the current plugin selects a wagon protocol, but it could be by-protocol in the repository URL. Repositories prefixed with s3:// would automatically select the S3 wagon. Such a URL is seen here

One approach is to use to publish from a local directory/repository. I haven’t used this approach in anger so I’m not sure how robust it is.

ext {
  distDir = "$buildDir/dist"
  publishing {
  repositories {
    maven {
      url = file(distDir)
  publications {
    yourPublication(MavenPublication) {
      from components.web
        artifact packageSources {
        classifier "sources"
  task s3deploy(type: S3Sync) {
  description = "Deploys to S3 bucket"
    accessKey amazonKey
  secretKey amazonSecret
  configFile "$rootDir/gradle/"
  from distDir
  into ""
  s3deploy.dependsOn publish

Really appreciate your help, Adrian!

Unfortunately, I’m still struggling to make it work. Have started with downloading task and having this basic setup it constantly gives me the following exception:

Execution failed for task ':deploy'.
> Neither path nor baseDir may be null or empty string. path='null'...

Gradle 2.1. Ubuntu 14.04 64bit. Gradle wrapper of version 1.12 didn’t help either. contains only acl=PRIVATE and I don’t have any file in my system.