Wiki source code of WebJar Maven Handler

Last modified by Thomas Mortagne on 2017/01/24 11:02

Show last authors
1 An issue with webjars for Extension Manager is that it's not possible to differentiate them from "real" JARs with classes in it.
2
3 To workaround this issue we introduces this Maven handled which allow us to have a more explicit ##<packaging>webjar</packaging>## in a webjar project pom.xml. This handler also automate all the plumbing required to make a webjar a webjar.
4
5 All you have to so is:
6 * put the webresources in src/main/webjar
7 * declare the packaging to be ##webjar## as in:(((
8 {{code language="xml"}}
9 <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">
10 <modelVersion>4.0.0</modelVersion>
11 <parent>
12 <groupId>org.xwiki.platform</groupId>
13 <artifactId>xwiki-platform-job</artifactId>
14 <version>9.0-SNAPSHOT</version>
15 </parent>
16 <packaging>webjar</packaging>
17 <artifactId>xwiki-platform-job-webjar</artifactId>
18 </projectr>
19 {{/code}}
20 )))
21 * optionally register the extension so that ##webjar## is recognized (not needed if you have platform pom >= 9.0 as parent):(((
22 {{code language="xml"}}
23 <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">
24 <modelVersion>4.0.0</modelVersion>
25 <parent>
26 <groupId>org.xwiki.platform</groupId>
27 <artifactId>xwiki-platform-job</artifactId>
28 <version>9.0-SNAPSHOT</version>
29 </parent>
30 <packaging>webjar</packaging>
31 <artifactId>xwiki-platform-job-webjar</artifactId>
32 <build>
33 <extensions>
34 <!-- Needed to add support for the "webjar" packaging -->
35 <extension>
36 <groupId>org.xwiki.commons</groupId>
37 <artifactId>xwiki-commons-tool-webjar-handlers</artifactId>
38 <version>${commons.version}</version>
39 </extension>
40 </extensions>
41 </build>
42 </project>
43 {{/code}}
44 )))

Get Connected