How to create a gradle-plugin that extends projects with specific publishing tasks?

I have seen the general documentation on how to create custom gradle plugins (Developing Custom Gradle Plugins). Projects implementing my custom plugin already have such a simple task.

Now, I’d like to prepare a specific publishing task and share it with some projects. However, I get errors (already in my plugin project) as soon as I start adding configurations for the publishing task.

Could anyone point me in the right direction on how to extend the publishing configurations of projects that implement my custom plugin?