Hi,
I'm trying to follow the Create a Confluence 'Hello World' Macro tutorial but upon reaching the 'Create a Macro Element in Confluence' step, my helloworld macro fails to appear in the macro browser.
From the tutorial, the atlassian-plugin.xml was updated to include xhtml-macro tag:
<xhtml-macro name="helloworld" class="com.atlassian.tutorial.macro.helloworld" key='helloworld-macro'>
<description key="helloworld.macro.desc"/>
<category name="formatting"/>
<parameters/>
</xhtml-macro>
The properties for the plugin were updated:
#put any key/value pairs here
my.plugin.name=MyPlugin
helloworld.macro.desc="Hello World"
I also added the helloworld.java file in /src/main/java/com/atlassian/tutorial/macro:
package com.atlassian.tutorial.macro;
import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.macro.Macro;
import com.atlassian.confluence.macro.MacroExecutionException;
import java.util.Map;
public class helloworld implements Macro {
public String execute(Map<String, String> map, String s, ConversionContext conversionContext) throws MacroExecutionException {
return "<h1>Hello World!</h1><h2>Test</h2>";
}
public BodyType getBodyType() { return BodyType.NONE; }
public OutputType getOutputType() { return OutputType.BLOCK; }
}
Eventually I tried pulling the source code from bitbucket. I'd made a simple mistake and added the xhtml-macro tag as a child of the web-resource tag instead of after it:
<web-resource key="myConfluenceMacro-resources" name="myConfluenceMacro Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="myConfluenceMacro.css" location="/css/myConfluenceMacro.css"/>
<resource type="download" name="myConfluenceMacro.js" location="/js/myConfluenceMacro.js"/>
<resource type="download" name="images/" location="/images"/>
<context>myConfluenceMacro</context>
<xhtml-macro name="helloworld" class="com.atlassian.tutorial.macro.helloworld" key='helloworld-macro' hidden="false">
<description key="helloworld.macro.desc"/>
<category name="formatting"/>
<parameters />
</xhtml-macro>
</web-resource>
<web-resource key="myConfluenceMacro-resources" name="myConfluenceMacro Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="myConfluenceMacro.css" location="/css/myConfluenceMacro.css"/>
<resource type="download" name="myConfluenceMacro.js" location="/js/myConfluenceMacro.js"/>
<resource type="download" name="images/" location="/images"/>
<context>myConfluenceMacro</context>
</web-resource>
<xhtml-macro name="helloworld" class="com.atlassian.tutorial.macro.helloworld" key='helloworld-macro' hidden="false">
<description key="helloworld.macro.desc"/>
<category name="formatting"/>
<parameters />
</xhtml-macro>
Maybe the instruction "Locate the end of the <web-resource>...</web-resource> section in the file and enter the following:" should be updated to say "Locate the end of the <web-resource>...</web-resource> section in the file and enter the following after the closing web-resource tag"?
Hopefully this helps others going forward!
great answer, save me time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
rrr, did exactly the same thing ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot!
It saved me the evaning! I was desperate.!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same problem here three years later. Tutorial is very unclear:
"Locate the end of the <web-resource>...</web-resource> section in the file and enter the following:"
How about "Locate the end of the <web-resource>...</web-resource> section in the file and insert the following after:"
or even...
"Locate the </atlassian-plugin> end tag and insert the following just before it:"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same problem here. But also having problems, in general, getting the macro to appear.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it's the bad you haven't change that in the tutorial and all newcomer gat the same f** problem with in (((
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.