Extending AbstractCopyTask for S3 / cloud object storage

I need to copy some task outputs to an S3 bucket, and I can’t find any obvious first-party ways of doing it. The third-party plugins I’ve found all seem to be require explicit setting of file name and object key, rather than an approach more like the AbstractCopyTask-based tasks like Jar or Zip (or Copy…).

I’ve looked for examples on how I might implement a task that extends AbstractCopyTask and implements whatever bits need implementing to upload objects rather than, say, creating a .zip, and I haven’t found anything useful.

Can anyone here recommend a starting point for understanding how to do this?

Thanks!

If you want to do it "like Jar, Zip, or Copy, why not looking at them for inspiration? :slight_smile:

Because I can’t follow the rats nest of indirection, or figure out which of the interface methods are important for what I want to do, which is why I’m looking for examples…

I had a quick look at Copy, seems quite easy to follow imho. :slight_smile:

abstract class CustomCopy : AbstractCopyTask() {
    override fun createCopyAction() = CopyAction {
        it.process {
            println("Uploading ${it.file} to AWS")
        }
        WorkResults.didWork(true)
    }
}

val foo by tasks.registering(CustomCopy::class) {
    from(configurations.testRuntimeClasspath)
}

=>

> Task :foo
Uploading ~\.gradle\caches\modules-2\files-2.1\org.spockframework\spock-core\2.3-groovy-4.0\8861b2590bb8e4709b052fb4ed6da3de98e734d9\spock-core-2.3-groovy-4.0.jar to AWS
Uploading ~\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-engine\1.9.0\bd46891f01817b5ffdd368cb0482a34746610acb\junit-platform-engine-1.9.0.jar to AWS
Uploading ~\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-commons\1.9.0\b727889107fc28c7460b21d1083212f8ce7602c6\junit-platform-commons-1.9.0.jar to AWS
Uploading ~\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-launcher\1.9.0\367a24bb63baca99a181ea921da8e21af0656e7c\junit-platform-launcher-1.9.0.jar to AWS
Uploading ~\.gradle\caches\modules-2\files-2.1\org.apache.groovy\groovy\4.0.4\1199db7007c16a37dd5fdba3163b86f290460a\groovy-4.0.4.jar to AWS
Uploading ~\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest\2.2\1820c0968dba3a11a1b30669bb1f01978a91dedc\hamcrest-2.2.jar to AWS
Uploading ~\.gradle\caches\modules-2\files-2.1\org.opentest4j\opentest4j\1.2.0\28c11eb91f9b6d8e200631d46e20a7f407f2a046\opentest4j-1.2.0.jar to AWS

The main problem I see is, that CopyAction, CopyActionProcessingStream, CopyActionProcessingStreamAction, and FileCopyDetailsInternal are internal classes.