How can I make a custom Archive Task?

I want to make a custom archive task based on executing javafxpackager. I want this to produce an artifact that would automatically be included as an archive that can be published with the “maven-publish” plugin. Just like the default Archive tasks (e.g. jar) so I could do:

artifacts {

archives jarfx

}

I tried:

task jarfx(type: AbstractArchiveTask, dependsOn: preparePackage) {

destinationDir = “${projectDir/dist”

archiveName = jar.archiveName

inputs.dir = “build/Package”

}

jarfx << {

// what it takes to exec javafxpackager

}

But that results in: “Cannot create a proxy class for abstract class ‘AbstractArchiveClass’”

What is the right way to do this?

You’d have to implement a class that extends AbstractArchiveTask. However, that class isn’t currently designed for extension from outside the Gradle code base. Until that’s fixed, the best solution is to implement your own task(s) from scratch. E.g your task could create a staging dir which could then be zipped with a regular Zip task (if appropriate).