PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/content/server/framework/atlassian-sdk/content-for-plugin-descriptor.snippet.md

https://bitbucket.org/zchristmas/atlassian-sdk-docs
Markdown | 358 lines | 304 code | 54 blank | 0 comment | 0 complexity | 966ea68a074336236e93c3e202b10930 MD5 | raw file
Possible License(s): LGPL-2.0
  1. ---
  2. aliases:
  3. - /server/framework/atlassian-sdk/-content-for-plugin-descriptor-852011.html
  4. - /server/framework/atlassian-sdk/-content-for-plugin-descriptor-852011.md
  5. category: devguide
  6. confluence_id: 852011
  7. dac_edit_link: https://developer.atlassian.com/pages/editpage.action?cjm=wozere&pageId=852011
  8. dac_view_link: https://developer.atlassian.com/pages/viewpage.action?cjm=wozere&pageId=852011
  9. date: '2017-12-08'
  10. legacy_title: _Content for Plugin Descriptor
  11. platform: server
  12. product: atlassian-sdk
  13. subcategory: other
  14. title: _Content for Plugin Descriptor
  15. ---
  16. # \_Content for Plugin Descriptor
  17. Every plugin requires an `atlassian-plugin.xml` file. This is a single file also known as the *plugin descriptor*. The plugin descriptor is an XML file that describes a plugin and the modules contained within it for the host application. In a plugin project, the file is resides in the `resources` directory. In a plugin submission, the descriptor is located at the root of the plugin's jar file.
  18. The following is a basic descriptor file:
  19. ``` xml
  20. <!-- Every plugin must have a key, which identifies the plugin uniquely to the system -->
  21. <!-- and a name, which is used to display the plugin in menus. -->
  22. <atlassian-plugin key="com.atlassian.confluence.plugins.example" name="The Customizer" plugins-version="2">
  23. <!-- The plugin info block allows you to provide more information about your plugin -->
  24. <plugin-info>
  25. <description>
  26. A sample plugin for demonstrating the file format.
  27. </description>
  28. <!-- This version is displayed in the application's Plugin Manager. -->
  29. <version>1.0</version>
  30. <!-- The versions of the application this plugin is compatible with -->
  31. <application-version min="1.3" max="1.3"/>
  32. <vendor name="Atlassian Software Systems Pty Ltd" url="http://www.atlassian.com/"/>
  33. <!-- The location of any plugin configuration (optional) -->
  34. <param name="configure.url">/admin/plugins/example/configurePlugin.action</param>
  35. <!-- Specifically declare bundle instructions (optional) -->
  36. <bundle-instructions>
  37. <Export-Package>my.external.pkg</Export-Package>
  38. <Import-Package>com.mylibrary,*;resolution:=optional</Import-Package>
  39. </bundle-instructions>
  40. </plugin-info>
  41. <!-- Here is where you define your modules. The code you use -->
  42. <!-- to define a module depends on the module itself. This is just -->
  43. <!-- a sample, which will not load if installed into Confluence -->
  44. <!-- Modules must have a key that is unique within the plugin, a name -->
  45. <!-- and an implementing class. -->
  46. <examplemodule key="module1" name="Example Module" class="com.atlassian.confluence.plugins.example.ExampleModule">
  47. <!-- All modules can optionally have a description -->
  48. <description>An example module</description>
  49. </examplemodule>
  50. </atlassian-plugin>
  51. ```
  52. The following sections describe the basic elements in the descriptor XML file.
  53. ## `atlassian-plugin` element
  54. The root element for your plugin descriptor. For example, the plugin descriptor file should have this structure:
  55. ``` xml
  56. <atlassian-plugin key="com.atlassian.confluence.plugins.example" name="The Customizer" plugins-version="2">
  57. <!-- ... -->
  58. </atlassian-plugin>
  59. ```
  60. <table>
  61. <colgroup>
  62. <col style="width: 50%" />
  63. <col style="width: 50%" />
  64. </colgroup>
  65. <thead>
  66. <tr class="header">
  67. <th><p>Attribute</p></th>
  68. <th><p>Description</p></th>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. <tr class="odd">
  73. <td><p><code>key</code></p></td>
  74. <td><p>A String identifying the plugin module. This attribute is required and must be unique within the plugin. You should use the reverse domain name notation to ensure your key is unique. In other contexts, you may need to uniquely identify a module. You should use the complete module key.<br />
  75. <br />
  76. By default, the SDK generation commands sets the key for you by referencing and concatenating the <code>groupId</code> and <code>artifactId</code> from the <code>pom.xml</code>.</p></td>
  77. </tr>
  78. <tr class="even">
  79. <td><p><code>name</code></p></td>
  80. <td><p>This is a human-readable name, used for display in menus within the application. By default, the SDK generation commands sets the key for you by referencing the add-on <code>name</code> from the <code>pom.xml</code>. You should not use the words 'plugin' or 'add-on' in this value.</p></td>
  81. </tr>
  82. <tr class="odd">
  83. <td><p><code>state</code></p></td>
  84. <td><p>This is <code>enabled</code> by default. To disable the entire plugin, specify <code>disabled</code>.</p></td>
  85. </tr>
  86. <tr class="even">
  87. <td><p><code>plugins-version</code></p></td>
  88. <td><p>To create an OSGi plugin, use <code>plugins-version=&quot;2&quot;</code>.<br />
  89. NOTE: The attribute <code>pluginsVersion</code> was <strong>deprecated</strong> in version 2.1 of the plugin framework.</p></td>
  90. </tr>
  91. <tr class="odd">
  92. <td><p><code>i18n-name-key</code></p></td>
  93. <td><p>The localization key for the human-readable name of the plugin module.</p></td>
  94. </tr>
  95. <tr class="even">
  96. <td><p><code>class</code></p></td>
  97. <td><p>The class that implements this plugin module. The class you need to provide depends on the module type. For example, Confluence theme, layout and colour-scheme modules can use classes already provided in Confluence. So you can write a theme-plugin without any Java code. But for macro and listener modules you need to write your own implementing class and include it in your plugin.</p></td>
  98. </tr>
  99. <tr class="odd">
  100. <td><p><code>system</code></p></td>
  101. <td><p>Indicates whether this plugin module is a system plugin module (value='true') or not (value='false'). Only available for non-OSGi plugins.</p></td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. ## `plugin-info` Element
  106. Contains plugin information displayed by the application for administrators, plugin parameters, and OSGi bundle instructions. Its parent element is `<atlassian-plugin>`, and it supports several nested elements.
  107. <table>
  108. <colgroup>
  109. <col style="width: 50%" />
  110. <col style="width: 50%" />
  111. </colgroup>
  112. <thead>
  113. <tr class="header">
  114. <th><p>Nested element</p></th>
  115. <th><p>Description</p></th>
  116. </tr>
  117. </thead>
  118. <tbody>
  119. <tr class="odd">
  120. <td><p><code>&lt;description&gt;</code></p></td>
  121. <td><p>A human-readable description of your plugin.</p></td>
  122. </tr>
  123. <tr class="even">
  124. <td><p><code>&lt;version&gt;</code></p></td>
  125. <td><p>The version of your plugin. This number is displayed in the application's plugin manager.</p></td>
  126. </tr>
  127. <tr class="odd">
  128. <td><p><code>&lt;java-version</code></p></td>
  129. <td><p>The Java version required for this plugin module. This is an optional value. It is not used consistently among the host applications.</p></td>
  130. </tr>
  131. <tr class="even">
  132. <td><p><code>&lt;application-version&gt;</code></p></td>
  133. <td><p>Supply the versions of the application that will support your plugin. Deprecated.</p></td>
  134. </tr>
  135. <tr class="odd">
  136. <td><p><code>&lt;vendor&gt;</code></p></td>
  137. <td><p>Supply information about the developer of the plugin.</p></td>
  138. </tr>
  139. <tr class="even">
  140. <td><p><code>&lt;param&gt;</code></p></td>
  141. <td><p>Supply parameter values if required by your plugin.</p></td>
  142. </tr>
  143. <tr class="odd">
  144. <td><p><code>&lt;bundle-instructions&gt;</code></p></td>
  145. <td><p>Declare plugin dependencies and shorten your export package lists by specifying OSGi bundle instructions directly in the plugin XML (OSGi plugins only).</p></td>
  146. </tr>
  147. </tbody>
  148. </table>
  149. These nested elements are described in more detail below.
  150. ### `description` element
  151. Describes your plugin. Its parent element is `<plugin-info>`.
  152. ``` xml
  153. <atlassian-plugin ...>
  154. <plugin-info>
  155. <!-- ... -->
  156. <description>New macros for integration with Acme Corp. web services</description>
  157. </plugin-info>
  158. </atlassian-plugin>
  159. ```
  160. ### `version` element
  161. The current version of your plugin. Its parent element is `<plugin-info>`. The UPM sometimes compares the plugin version value within an application to determine the newer version, particularly when performing automated upgrades. Versions are compared by splitting the version number into components and comparing them numerically first and alphabetically second.
  162. Following are some sample version numbers in ascending order: 0.99, 1.0, 1.0.1-alpha, 1.0.1-beta, 1.0.1-beta2, 1.0.1, 1.0.1.0, 1.1, 1.2, 1.10, 2.0.
  163. ``` xml
  164. <atlassian-plugin ...>
  165. <plugin-info>
  166. <!-- ... -->
  167. <version>1.2</version>
  168. </plugin-info>
  169. </atlassian-plugin>
  170. ```
  171. ### `application-version` element
  172. {{% note %}}
  173. Deprecated since Atlassian Plugin Framework 2.2
  174.  
  175. {{% /note %}}
  176. Describe which versions of the host application are compatible with this plugin. Enforcement of this property varies between applications: some applications strictly enforce compatibility, while others ignore the value.
  177. Its parent element is `<plugin-info>`.
  178. <table>
  179. <colgroup>
  180. <col style="width: 50%" />
  181. <col style="width: 50%" />
  182. </colgroup>
  183. <thead>
  184. <tr class="header">
  185. <th><p>Attribute name</p></th>
  186. <th><p>Description</p></th>
  187. </tr>
  188. </thead>
  189. <tbody>
  190. <tr class="odd">
  191. <td><p><code>min</code></p></td>
  192. <td><p>Lowest application version that your plugin is compatible with.</p></td>
  193. </tr>
  194. <tr class="even">
  195. <td><p><code>max</code></p></td>
  196. <td><p>Highest application version that your plugin is compatible with.</p></td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. ``` xml
  201. <atlassian-plugin ...>
  202. <plugin-info>
  203. <!-- ... -->
  204. <application-version min="2.0" max="2.7" />
  205. </plugin-info>
  206. </atlassian-plugin>
  207. ```
  208. ### `vendor` element
  209. The plugin vendor. Provides a link in the plugin administration screens. Its parent element is `<plugin-info>`.
  210. <table>
  211. <colgroup>
  212. <col style="width: 50%" />
  213. <col style="width: 50%" />
  214. </colgroup>
  215. <thead>
  216. <tr class="header">
  217. <th><p>Attribute name</p></th>
  218. <th><p>Description</p></th>
  219. </tr>
  220. </thead>
  221. <tbody>
  222. <tr class="odd">
  223. <td><p><code>name</code></p></td>
  224. <td><p>Supply your name or the name of the company you work for.</p></td>
  225. </tr>
  226. <tr class="even">
  227. <td><p><code>url</code></p></td>
  228. <td><p>Supply a web site address.</p></td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. ``` xml
  233. <atlassian-plugin ...>
  234. <plugin-info>
  235. <!-- ... -->
  236. <vendor name="Acme Systems Ltd" url="http://acme.example.com/" />
  237. </plugin-info>
  238. </atlassian-plugin>
  239. ```
  240. ### `param` element
  241. Arbitrary parameters for a plugin. Its parent element is `<plugin-info>`. These can be nested in many other elements. Attribute `name` gives the parameter name. The element's body is its value.
  242. <table>
  243. <colgroup>
  244. <col style="width: 50%" />
  245. <col style="width: 50%" />
  246. </colgroup>
  247. <thead>
  248. <tr class="header">
  249. <th><p>Attribute</p></th>
  250. <th><p>Description</p></th>
  251. </tr>
  252. </thead>
  253. <tbody>
  254. <tr class="odd">
  255. <td><p><code>name</code></p></td>
  256. <td><p>The name of the parameter.</p></td>
  257. </tr>
  258. <tr class="even">
  259. <td><p>(body)</p></td>
  260. <td><p>The value of the parameter.</p></td>
  261. </tr>
  262. </tbody>
  263. </table>
  264. A common example of a `param` element the URL for your plugin's configuration screen. Below is an example.
  265. ``` xml
  266. <atlassian-plugin ...>
  267. <plugin-info>
  268. <!-- ... -->
  269. <param name="configure.url">/admin/plugins/example/configurePlugin.action</param>
  270. </plugin-info>
  271. </atlassian-plugin>
  272. ```
  273. ### `bundle-instructions` element
  274. This element allows you to declare plugin dependencies and shorten your export package lists by specifying OSGi bundle instructions directly in the plugin XML. The element's parent element is `<plugin-info>`.
  275. ``` xml
  276. <atlassian-plugin ...>
  277. <plugin-info>
  278. <!-- ... -->
  279. <bundle-instructions>
  280. <Export-Package>my.external.pkg</Export-Package>
  281. <Import-Package>com.mylibrary,*;resolution:=optional</Import-Package>
  282. </bundle-instructions>
  283. </plugin-info>
  284. </atlassian-plugin>
  285. ```
  286. As seen in the above example, the `bundle-instructions` element allows child elements, including:
  287. - `<Export-Package>`
  288. - `<Import-Package>`
  289. Alternatively, you can declare these instruction sets inside your `pom.xml` file.
  290. {{% note %}}
  291. Speeding up Plugin Loading
  292. [How to Speed Up Plugin Startup](/server/framework/atlassian-sdk/how-to-speed-up-plugin-startup) contains information on using bundle instructions for speeding plugin start up.
  293. {{% /note %}}
  294. The Atlassian Plugin Framework uses the <a href="http://www.aqute.biz/Code/Bnd" class="external-link">bnd</a> tool to generate OSGi bundles. This tool is available as the <a href="http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html" class="external-link">Bundle Plugin for Maven</a>. For details of the bnd directives, please refer to the <a href="http://www.aqute.biz/Code/Bnd#directives" class="external-link">bnd documentation</a>.
  295. ## Plugin module elements
  296. In the rest of the descriptor XML file, contains any modules that make up your plugin. You can add these modules through the `atlas-`\* commands or manually. The following illustrates the addition of a `web-item` module:
  297. ``` xml
  298. <web-item name="Radio Paradise" i18n-name-key="radio-paradise.name" key="radio-paradise" section="client-sites-link/my-section" weight="1000">
  299. <description key="radio-paradise.description">The Radio Paradise Plugin</description>
  300. <label key="radio-paradise.label"></label>
  301. <link linkId="radio-paradise-link">http://www.radioparadise.com</link>
  302. </web-item>
  303. ```
  304. For more information about the modules a plugin can contain, refer to the list of module types for your plugin's host application.