How do I include CSS in a XWiki rendering Macro written in Java?

How can I include CSS in a XWiki rendering Macro written in Java (XWiki-Version: 16.8.0)? It seems that a while ago “SkinExtension” was used for somthing like this, but that does not seem to be the right option nowadays. I do not want to embed the CSS in the output of the Macro, but would prefer to “register” the CSS somehow globally.

I use the following calls for css declarations, which are computed within a macro.
The css declarations will be loaded after the standard skins.

// cssText contains the css declarations
xwiki.linkx.use("data:text/css,"+cssText, ['type': 'text/css', 'rel': 'stylesheet'])
// or this to avoid syntax conflicts within data: 
xwiki.linkx.use("data:text/css;base64," +cssText.bytes.encodeBase64().toString(), ['type': 'text/css', 'rel': 'stylesheet'])

Norbert

You can include a CSS file in the JAR similar to this example for required rights or toc.css for the table of contents macro (but using a longer path similar to the required rights example seems better to avoid conflicts) and then load it as skin extension as shown in the TOC macro. There is nothing wrong with using skin extensions.