How to create a Java task of type Jar that implements the from method of CopSpec?

(Sara Fatih) #1

I have a task in the build.gradle file as follows:
task jar(type: Jar, overwrite: true) {
from("${buildDir}/generatedClasses")
}
And I am creating a Java class that extends DefaultTask and that should do exactly this but in Java as follows:
public class JarTask extends DefaultTask {
@TaskAction
public void jar() { }
}

How can I implement the from method?