Embed gradle in jar?

There are multiple Java applications (jars which are built and maintained independently) that we run during build using custom task types for each application.

These custom tasks are usually project.exec on jar files with @Input properties and some preprocessing.

One idea is to have all custom tasks for all such jars in one separate plugin.

Another is to have one gradle plugin for each of those Java applications.

I think it would be much simpler if we can make gradle plugin or custom tasks and embed them with those jars so that they can just be imported in another project and those tasks can be used?

Is there a way to do that? Is it a standard problem with a standard solution?