First Things to Do in a Confluence Skeleton Plugin

Posted by admin on April 19th, 2014 filed in Development, Java, Wiki

Here are the first things I do right after creating and testing the skeleton project of an advanced Confluence Bluepint plugin.

In atlassian-plugin.xml (the plugin descriptor), do the following:

  • Here you link an icon and logo in the <plugin-info> element. Copy your organization icon and logo PNG files to the “images/” directory (as you see it done in the skeleton project).
  • Be aware for the future that, every time you add an XML, Soy, Java, or JavaScript file, you have to declare that here. I’ll go into more detail in another blog article.

In the pom.xml, do the following:

  1. Specify your organization name and url.
        <organization>
            <name>Company Inc</name>
            <url>http://company.com/</url>
        </organization>

    Here is also where you set the plugin version from SNAPSHOT to 1.0 when you release it.

  2. Add your current maven-compiler-plugin version. Run atlas-version to find out what it is.
    
            ...
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                    <version>2.5</version>
                </plugin>
            </plugins>
        </build>
  3. I set the confluence version property to a stable release (5.3). By default it was a dot release (5.4.3 or 5.4.4) which threw lots of errors for me for some reason.
  4. Apparently the plugin’s <name> is lost by the wizard and not set in the skeleton, so I retyped it.

In the XML, SOY, and Java files, do the following:

  1. src\main\resources\kbarticle.properties — Define all static UI text using Java-style .properties resourceBundle files. UI text includes text in wizard dialogs (dialog-wizard.js), wizard error messages, placeholder text, the page template (article-template.xml), the plugin name, and description. Using ResourceBundles consistently will make localization and text changes easy later.
  2. src\main\resources\soy\article-wizard.soy — Here you define the form fields of the wizard UI. You link input fields to Java context variables through the “name=” attribute.
    In the following example, the text field with id customername is linked to the Java variable customerName. The static text is defined in the .properties file as my.blueprint.form.label.title.customername.

    {namespace MyPlugin.Blueprints.Simple}
    /**
    *  A simple wizard form that accepts a person's name
    */
    {template .page1Form}
        <form action="#" method="post" class="aui">
          <fieldset>
            <div class="field-group">
                <label for="customername">{getText(
                    'my.blueprint.form.label.title.customername')}</label>
                <input id="customername" class="text" type="text" name="customerName">
            </div>
          </fieldset>
        </form>
    {/template} 
    
  3. src\main\resources\xml\article-template.xml: Define the blueprint template for your new page. This file contains static HTML text, and dynamic <at:var> variables.
    1. Define dynamic variables through context.put(myVariable,"blah"); in ContentTemplateContextProvider.java, and then use them here through <at:var at:name="myVariable" /> .
    2. Define static text in the .properties files and use it here through <ac:placeholder><at:i18n at:key="com.my.company.kbarticle.mytemplate.myplaceholder" /></ac:placeholder> .
  4. src\main\java\ — Write your ContextProvider (to define dynamic data for substitution in the article template’s <at:var> elements), write your EventListener (to run Java code after page creation), and write your serialization classes.
    Tip: In the ContextProvider, I changed the declaration to
    public class ContentTemplateContextProvider extends AbstractBlueprintContextProvider.

Sources: simple blueprint plugin, intermediate blueprint plugin, advanced blueprint plugin

Comments are closed.