Publish to Amazon S3

I found a reference here

https://twitter.com/ldaley/status/167617758283051008

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

https://github.com/gradle/gradle/blob/master/subprojects/website/website.gradle#L316

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?

Thanks.

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

https://github.com/jcaddel/maven-s3-wagon

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

https://github.com/SpringSource/aws-maven

One approach is to use https://github.com/literalice/gradle-aws-s3-sync 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"
      }
    }
  }
}
  import com.monochromeroad.gradle.plugin.aws.s3.S3Sync
  task s3deploy(type: S3Sync) {
  description = "Deploys to S3 bucket"
    accessKey amazonKey
  secretKey amazonSecret
  configFile "$rootDir/gradle/jets3t.properties"
  from distDir
  into "artifact.yourdomain.com/maven/release"
}
  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.

synchronizer.properties contains only acl=PRIVATE and I don’t have any jets3t.properties file in my system.