Wiki source code of Extension Maven Plugin
Last modified by Thomas Mortagne on 2022/08/01 13:52
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{box cssClass="floatinginfobox" title="**Contents**"}} | ||
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
5 | Various extension-oriented mojos for Maven builds. | ||
6 | |||
7 | = WAR Mojo = | ||
8 | |||
9 | Generate a complete extension descriptor (##.xed## file) for all the jars packaged in a WAR (next to each one) as well as for the WAR itself (in ##/META-INF/##). | ||
10 | |||
11 | To execute it: | ||
12 | |||
13 | {{code language="xml"}} | ||
14 | <plugin> | ||
15 | <groupId>org.xwiki.commons</groupId> | ||
16 | <artifactId>xwiki-commons-tool-extension-plugin</artifactId> | ||
17 | <executions> | ||
18 | <execution> | ||
19 | <goals> | ||
20 | <goal>war</goal> | ||
21 | </goals> | ||
22 | </execution> | ||
23 | </executions> | ||
24 | </plugin> | ||
25 | {{/code}} | ||
26 | |||
27 | = Register Mojo = | ||
28 | |||
29 | Generate complete extension descriptor (##.xed## file) for the current artifact in ##/META-INF/##. | ||
30 | |||
31 | {{code language="xml"}} | ||
32 | <plugin> | ||
33 | <groupId>org.xwiki.commons</groupId> | ||
34 | <artifactId>xwiki-commons-tool-extension-plugin</artifactId> | ||
35 | <executions> | ||
36 | <execution> | ||
37 | <goals> | ||
38 | <goal>register</goal> | ||
39 | </goals> | ||
40 | </execution> | ||
41 | </executions> | ||
42 | </plugin> | ||
43 | {{/code}} | ||
44 | |||
45 | = XIP Mojo and extension = | ||
46 | |||
47 | Generate a ##xip## package (a zip file containing extensions formatted like the local extensions repository) containing the dependencies of the current project by default. It's mostly used in conjunction with ##xip## extensions as a packaging tool. | ||
48 | |||
49 | To use it: | ||
50 | |||
51 | {{code language="xml"}} | ||
52 | <packaging>xip</packaging> | ||
53 | {{/code}} | ||
54 | |||
55 | If you don't use the right parent you might also need to register the ##xip## packaging in your pom: | ||
56 | |||
57 | {{code language="xml"}} | ||
58 | <build> | ||
59 | <extensions> | ||
60 | <!-- Needed to add support for the "xip" packaging --> | ||
61 | <extension> | ||
62 | <groupId>org.xwiki.commons</groupId> | ||
63 | <artifactId>xwiki-commons-tool-extension-plugin</artifactId> | ||
64 | <version>${commons.version}</version> | ||
65 | </extension> | ||
66 | </extensions> | ||
67 | </build> | ||
68 | {{/code}} | ||
69 | |||
70 | == Excluding dependencies == | ||
71 | |||
72 | It's possible to indicate a set of dependencies you don't want to include in your XIP (because they are expected to always be there in the target XWiki version) using for example: | ||
73 | |||
74 | {{code language="xml"}} | ||
75 | <build> | ||
76 | <pluginManagement> | ||
77 | <plugins> | ||
78 | <plugin> | ||
79 | <groupId>org.xwiki.commons</groupId> | ||
80 | <artifactId>xwiki-commons-tool-extension-plugin</artifactId> | ||
81 | <version>${commons.version}</version> | ||
82 | <configuration> | ||
83 | <coreExtensions> | ||
84 | <!-- We exclude what is already in the XWiki Standard WAR --> | ||
85 | <coreExtension> | ||
86 | <groupId>org.xwiki.platform</groupId> | ||
87 | <artifactId>xwiki-platform-distribution-war-dependencies</artifactId> | ||
88 | <version>${platform.version}</version> | ||
89 | <type>pom</type> | ||
90 | </coreExtension> | ||
91 | </coreExtensions> | ||
92 | </configuration> | ||
93 | </plugin> | ||
94 | </plugins> | ||
95 | </pluginManagement> | ||
96 | </build> | ||
97 | {{/code}} | ||
98 | |||
99 | == Example == | ||
100 | |||
101 | For example if you want to package a XIP package for an already released extension (in this example ##org.xwiki.contrib.mediawiki:mediawiki-xml##) you would generally create in an empty folder a pom.xml file similar to the following: | ||
102 | |||
103 | {{code}} | ||
104 | <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"> | ||
105 | <modelVersion>4.0.0</modelVersion> | ||
106 | <parent> | ||
107 | <groupId>org.xwiki.platform</groupId> | ||
108 | <artifactId>xwiki-platform-distribution</artifactId> | ||
109 | <!-- The version of XWiki where the extension is planned to be installed --> | ||
110 | <version>14.5</version> | ||
111 | </parent> | ||
112 | <groupId>mygroupid</groupId> | ||
113 | <artifactId>mediawiki-xml-xip</artifactId> | ||
114 | <packaging>xip</packaging> | ||
115 | <properties> | ||
116 | <!-- It's expected for some enforcer rules to fail with a dependency that was not designed to be built with this version of XWiki --> | ||
117 | <xwiki.enforcer.skip>true</xwiki.enforcer.skip> | ||
118 | </properties> | ||
119 | <dependencies> | ||
120 | <!-- The extension to package along with its dependencies--> | ||
121 | <dependency> | ||
122 | <groupId>org.xwiki.contrib.mediawiki</groupId> | ||
123 | <artifactId>mediawiki-xml</artifactId> | ||
124 | <version>1.13.5</version> | ||
125 | </dependency> | ||
126 | </dependencies> | ||
127 | <build> | ||
128 | <pluginManagement> | ||
129 | <plugins> | ||
130 | <plugin> | ||
131 | <groupId>org.xwiki.commons</groupId> | ||
132 | <artifactId>xwiki-commons-tool-extension-plugin</artifactId> | ||
133 | <version>${commons.version}</version> | ||
134 | <configuration> | ||
135 | <coreExtensions> | ||
136 | <!-- We exclude what is already in the WAR --> | ||
137 | <coreExtension> | ||
138 | <groupId>org.xwiki.platform</groupId> | ||
139 | <artifactId>xwiki-platform-distribution-war-dependencies</artifactId> | ||
140 | <version>${platform.version}</version> | ||
141 | <type>pom</type> | ||
142 | </coreExtension> | ||
143 | </coreExtensions> | ||
144 | </configuration> | ||
145 | </plugin> | ||
146 | </plugins> | ||
147 | </pluginManagement> | ||
148 | </build> | ||
149 | </project> | ||
150 | {{/code}} | ||
151 | |||
152 | You will genenrally use exactly the same pom with two differences: | ||
153 | |||
154 | * the version of XWiki in which you plan to install your extension (in ##<parent>##) | ||
155 | * the ##<dependencies>## you want to include in your XIP package | ||
156 | |||
157 | and execute | ||
158 | |||
159 | {{code language="sh"}} | ||
160 | mvn package | ||
161 | {{/code}} | ||
162 | |||
163 | = Common parameters = | ||
164 | |||
165 | All the Mojos above share a list of parameters. Some of them are described here. | ||
166 | |||
167 | == disabledComponents == | ||
168 | |||
169 | {{info}} | ||
170 | Since XWiki 12.2. | ||
171 | {{/info}} | ||
172 | |||
173 | This parameter allows to specify a list of components to unregister from the component manager. | ||
174 | Example of an usage: | ||
175 | |||
176 | {{code}} | ||
177 | <configuration> | ||
178 | <disabledComponents> | ||
179 | <disabledComponent> | ||
180 | <type>com.xpn.xwiki.doc.MandatoryDocumentInitializer</type> | ||
181 | <role>XWiki.XWikiServerXwiki</role> | ||
182 | </disabledComponent> | ||
183 | </disabledComponents> | ||
184 | </configuration> | ||
185 | {{/code}} | ||
186 | |||
187 | Note that if the role is not filled or given, the default hint will be used. |