Hi fellow Jenkins Devs :) I'd like to create a custom Jelly tag (Java, not a *.jelly template) and persuade Stapler to load it from my Jenkins plugin.
According to various bits and pieces of conversations I found around the Internet: http://mail-archives.apache.org/mod_mbox/commons-user/200411.mbox/%[email protected]%3E https://java.net/projects/hudson/lists/dev/archive/2010-09/message/255 I understand that it is possible, and that I should do the following: - in my plugin package (assume com.myplugin for the sake of simplicity) create the CustomTag.java (com.myplugin.CustomTag), that extends any public tag from org.kohsuke.stapler.jelly.* (since the AbstractStaplerTagis not available outside of the org.kohsuke.stapler.jelly package) - * it might not be necesary to extend any other tag, or is it?* - in the same package create the TagLibrary class, say MyCustomTagLibrary.java, extending org.apache.commons.jelly.TagLibrary, where I register my CustomTag class: public class CustomTagLibrary extends TagLibrary { public CustomTagLibrary() { registerTag("custom", CustomTag.class); } } - in the same package create an empty "taglib" file *I'm not sure if that's at all required?* - in my plugin's "main.jelly", where I'd like to use the custom tag, register the custom taglib by specifying: <j:jelly ... xmlns:mc="jelly:com.myplugin.MyCustomTagLibrary"> The code compiles and runs fine, but the custom tag code: <mc:custom ...> is not evaluated. What I managed to find out so far, is that Stapler's CustomJellyContext::getTagLibrary only allows me to retrieve those TagLibraries that have been previously explicitly registered. So I guess my question is: *How can I register a custom JellyTagLibrary from within the plugin?* I don't seem to be able to get hold of the CustomJellyContext class, which has the registerTagLibrary method on it? Please tell me I'm completely wrong, missing something obvious and there's a nice and simple way of achieving this goal :) Any suggestions would be greatly appreciated! -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
