Confluence Helloworld macro from SDK tutorials is not loading in macro browser

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.

confluence-macro-test.gif

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; }

}
 
2017-08-28 11_29_51-helloworld.java — jira-plugins — Visual Studio Code.png
I then ran atlas-mvn package as in the tutorial but that did not allow me to select the helloworld macro from the macro browser. I've also tried ctrl + Z shutting down the sdk application instances and restarting.
 
Is there a step missing from the tutorial?
 
Are there any known issues with the version of the sdk / application I'm running?
 
- confluence version: 5.10.7
- confluence data version: 5.10.5
- amps version: 6.2.11
- ATLAS Version: 6.2.14
- Java version: 1.8.0_121
 
Thanks,
Matt

1 answer

1 accepted

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!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

774 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you