Add generated class files from another plugin into a separate Jar


Plugin I am using generated class files that then I use in my project. What I would like to do though is to take these generated classes and package them into a Jar for distribution. So other projects don’t need to go through the same process of generating these class files.

What I tried is:

tasks.register('classJar', Jar) {
  dependsOn tasks.assemble
  doLast {
    from layout.buildDirectory.dir("classes/java/main/api/trc/").collect {

But it doesn’t work, am I totally on the wrong track or there is just a minor mistake here?

Tried also this:

FileFilter fileFilter = new FileFilter() {
  boolean accept(File pathname) {
    return pathname.isFile()

archiveFileName = "myCustom.jar"
from file("$buildDir/classes/java/main/api/trc/").listFiles(fileFilter).sort().collect() {

Above, I am not entirely sure how to assign this archiveFileName to the actual Jar I Want to make, found this in some example that in the meantime I can’t find anymore…

Also tried this:


include '**/*.class'

// Include the dependencies in the JAR file
from {
  configurations.runtimeClasspath.collect {
    it.isDirectory() ? it : zipTree(it)

But still I am getting no jar file. When I print out the files in the directory I am wanting to zip it shows files that I expect. Not sure where else to look for an error?