Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 There are 2 types of Extensions:
6
7 * XAR Extensions: they are wiki pages packaged in a [[format that is called XAR>>extensions:Extension.XAR Module Specifications]] (which stands for XWiki Archive). It's a ZIP file with a specific directory structure and an XML syntax to represent the wiki pages, along with a package metadata file.
8 * JAR Extensions: they are [[XWiki Components>>extensions:Extension.Component Module]] written in Java and packaged in a JAR.
9
10 = Creating a XAR Extension =
11
12 The simplest strategy is to create the wiki pages in a running XWiki instance and then to [[export them as a XAR>>platform:Features.Exports||anchor="HXARExport"]].
13
14 Note that those wiki pages can contain a lot of things:
15
16 * pure content,
17 * [[scripts>>platform:DevGuide.Scripting]],
18 * applications (you can even use the [[Applications Within Minutes application>>extensions:Extension.App Within Minutes Application]] to help create some simple application to match your needs),
19 * [[wiki macros>>platform:DevGuide.WikiMacroTutorial]],
20 * ... and a lot more
21
22 == Building a XAR with Maven ==
23
24 If you wish to save your XAR sources under [[version control>>https://en.wikipedia.org/wiki/Version_control]] and be able to build it, we recommend using [[Maven>>https://maven.apache.org/]]. There's a plugin called the [[XAR Maven plugin>>dev:Community.XARPlugin]] to help with this.
25
26 Here's how you can save the XAR you got when exporting pages from the wiki into your source tree:
27
28 * create a ##[ROOT]## directory to be the root of your Maven project
29 * add a ##pom.xml## file (see below for more details)
30 * unzip the XAR into the ##[ROOT]/src/main/resources## directory and remove the ##package.xml## file (you don't need to save it since the Maven XAR plugin will regenerate it)
31 * run ##mvn xar:format## to pretty format the wiki pages (XML files)
32 * run ##mvn install## to automatically perform validation and generate the XAR
33
34 === Authoring a Maven POM for a XAR ===
35
36 Here's an example of how your ##pom.xml## could look like (adapt to your need).
37
38 Notice the usage of a Contrib Parent POM which automatically provides configuration for lots of things. To know more about how to use the Contrib Parent POM check the [[documentation for it on GitHub>>https://github.com/xwiki-contrib/parent]].
39
40 {{code language="xml"}}
41 <?xml version="1.0" encoding="UTF-8"?>
42
43 <!--
44 * See the NOTICE file distributed with this work for additional
45 * information regarding copyright ownership.
46 *
47 * This is free software; you can redistribute it and/or modify it
48 * under the terms of the GNU Lesser General Public License as
49 * published by the Free Software Foundation; either version 2.1 of
50 * the License, or (at your option) any later version.
51 *
52 * This software is distributed in the hope that it will be useful,
53 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
55 * Lesser General Public License for more details.
56 *
57 * You should have received a copy of the GNU Lesser General Public
58 * License along with this software; if not, write to the Free
59 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
60 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
61 -->
62
63 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
64 <modelVersion>4.0.0</modelVersion>
65 <parent>
66 <groupId>org.xwiki.contrib</groupId>
67 <artifactId>parent-platform</artifactId>
68 <version>8.4-11</version>
69 </parent>
70 <groupId>org.xwiki.contrib</groupId>
71 <artifactId>your-extension-id</artifactId>
72 <version>1.0-SNAPSHOT</version>
73 <name>Your extension's name</name>
74 <packaging>xar</packaging>
75 <description>Your extension's description</description>
76 <scm>
77 <connection>scm:git:git://github.com/xwiki-contrib/(your extension id).git</connection>
78 <developerConnection>scm:git:[email protected]:xwiki-contrib/(your extension id).git</developerConnection>
79 <url>https://github.com/xwiki-contrib/(your extension id)</url>
80 </scm>
81 <developers>
82 <developer>
83 <id>scm id of developer 1</id>
84 <name>Full Name of developer 1 as registered on xwiki.org, e.g. Vincent Massol</name>
85 </developer>
86 ...
87 <developer>
88 <id>scm id of developer N</id>
89 <name>Full Name of developer N as registered on xwiki.org, e.g. Vincent Massol</name>
90 </developer>
91 </developers>
92 <properties>
93 <!-- Don't check for API backward-compatibility here since there's no Java code. -->
94 If you're using a xwiki-commons parent POM that is >= 8.1M1 then you need to use:
95 <xwiki.revapi.skip>true</xwiki.revapi.skip>
96 Otherwise you should use:
97 <xwiki.clirr.skip>true</xwiki.clirr.skip>
98
99 <!-- The Extension name. If not defined, the <name> property is used -->
100 <xwiki.extension.name>Your extension's name</xwiki.extension.name>
101
102 <!-- The extension's category -->
103 <xwiki.extension.category>application</xwiki.extension.category>
104
105 <!-- Issue management -->
106 <xwiki.release.jira.skip>false</xwiki.release.jira.skip>
107 <xwiki.issueManagement.jira.id>(your jira project id)</xwiki.issueManagement.jira.id>
108 </properties>
109 </project>
110 {{/code}}
111
112 See the section about Metadata below to understand what information you need to provide in your POM.
113
114 = Creating a JAR Extension =
115
116 XWiki has a notion of [[Components>>extensions:Extension.Component Module]], and this is how it provides extensibility at the level of Java. XWiki itself is written as a set of Components. This allows extension writers to author Components that can replace (i.e. override) existing Components or add new Components to the system.
117
118 Here are some examples:
119
120 * [[Add a new Macro>>rendering:Main.ExtendingMacro]],
121 * [[Write a Listener>>platform:DevGuide.WritingEventListenerTutorial]],
122 * [[Implement a new wiki markup syntax>>rendering:Main.Extending||anchor="HAddinganewSyntax"]],
123 * ... and a lot more
124
125 Follow the [[Creating an XWiki Component tutorial>>platform:DevGuide.WritingComponents]] to learn how to both develop a Component and use Maven to build it.
126
127 = Extension Metadata =
128
129 It's important that you set the following information as they'll be used by XWiki's Extension Manager when the extension is installed in XWiki (see below):
130
131 * Extension id (##<groupId>## and ##<artifactId>##), e.g. ##org.xwiki.contrib.blog## and ##application-blog-ui##.
132 * Name. This is the user-friendly name of your extension and it's displayed on http://extensions.xwiki.org. Specify it using the ##<xwiki.extension.name>## maven property. E.g. ##Blog Application##.
133 * Description. Keep it to one sentence. It's displayed on http://extensions.xwiki.org.
134 * Developers
135 * Category (using ##<xwiki.extension.category>##). Valid values are [[listed here>>extensions:Extension.Repository Application||anchor="HCategories"]].
136 * SCM (Note: this is also required by the Maven Release plugin if you use it to release your extension)
137 * Issue Management (most of the time only the jira id as a Maven property like in the example)
138
139 If you've modified the ##groupId## or ##artifactId## of the extension you need to tell it to the Extension Manager so that it can handle upgrades and understand it's the same extension being upgraded. For example if the extension previously had an extension id of ##tdelafosse:meeting-application## and you're now using another id, you need to add the following property to your ##pom.xml##:
140
141 {{code language="xml"}}
142 <properties>
143 ...
144 <!-- Old names of this module used for retro compatibility when resolving dependencies of old extensions -->
145 <xwiki.extension.features>tdelafosse:meeting-application</xwiki.extension.features>
146 ...
147 </properties>
148 {{/code}}
149
150 {{info}}
151 In addition you need to pay attention to the version of the dependencies you're going to use (for example the version of your parent POM). If you wish your extension to be used by the maximum number of XWiki users you need to use the oldest dependencies version for which you extension still works. At worse, try to use the LTS version. This is because your extension will only be able to be installed in XWiki versions satisfying those dependencies you expressed.
152
153 LTS are always provided for https://github.com/xwiki-contrib/parent, in case the version you want is not listed you can:
154
155 * use the closest LTS as parent but use a different version for the dependencies
156 * ask for it to be released in the Mailing List
157 {{/info}}
158
159 = Installing an Extension =
160
161 There are 2 ways but the recommended one is to use the [[Extension Manager>>extensions:Extension.Extension Manager Application]] which you can find in the XWiki instance where you wish to install the extension in.
162
163 == Using the Extension Manager ==
164
165 The advantage over the Manual way is that you don't need to regularly start/stop your XWiki instance and thus you don't occur the start wait times.
166
167 * Have a running XWiki instance configured with a local Extension Repository pointing to your Maven local Repository. Edit ##xwiki.properties## and make sure you have the following set:(((
168 {{code language="none"}}
169 extension.repositories=local:maven:file://${sys:user.home}/.m2/repository
170 extension.repositories=maven-xwiki:maven:http://nexus.xwiki.org/nexus/content/groups/public
171 extension.repositories=extensions.xwiki.org:xwiki:http://extensions.xwiki.org/xwiki/rest/
172 {{/code}}
173 )))
174 * Build your component and deploy it in your local Maven repository with ##mvn install##
175 * Inside your running XWiki instance, go to the Extension Manager in the Admin UI (e.g. ##{{{http://localhost:8080/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&section=XWiki.AddExtensions}}}##) and click on Advanced Search and enter your extension's id and version and follow the instructions. (##<groupId>:<artifactId>## , e.g: ##org.xwiki.contrib:your-extension-id##)
176
177 {{warning}}
178 If you want to redeploy an extension and it's already installed with the same version, the Extension Manager won't let you do so. Thus you'll need to uninstall it first using the Extension Manager. You'll also need to remove metadata in memory using the [[Extension Tweak>>extensions:Extension.Extension Tweak]].
179 {{/warning}}
180
181 == Manually ==
182
183 === For a XAR ===
184
185 * To build the component, issue ##mvn install##. This generates a XAR in the ##target## directory of your project.
186 * Inside your XWiki instance, go the Admin and [[Import the XAR>>platform:Features.Imports]].
187
188 === For a JAR ===
189
190 * To build the component, issue ##mvn install##. This generates a JAR in the ##target## directory of your project.
191 * To install it into a XWiki instance, just copy that JAR file in ##XE_WAR_HOME/WEB-INF/lib## where ##XE_WAR_HOME## is where the XWiki WAR is deployed.
192
193 = Deploying Extensions =
194
195 If you wish to make your extension available to others to use, the best is to contribute it on [[extensions.xwiki.org>>extensions:Main.WebHome]]. Go there and enter a name for your extension in the Contribute box and submit. Then document nicely your extension with instructions on how to use. The more screenshots the better! Here are some [[documentation guidelines>>contrib:Main.WebHome||anchor="HDocumenting"]].
196
197 Once your extensions is there, it means that any user of XWiki in the world will be able to find it and install it directly from his/her wiki!
198
199 You may also want to join a family and contribute your extension on [[XWiki Contrib>>contrib:Main.WebHome]] so that it is developed and maintained collaboratively.

Get Connected