WebJar Maven Handler

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

An issue with webjars for Extension Manager is that it's not possible to differentiate them from "real" JARs with classes in it.

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.

All you have to so is:

  • put the webresources in src/main/webjar
  • declare the packaging to be webjar as in:
    <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">
     <modelVersion>4.0.0</modelVersion>
     <parent>
       <groupId>org.xwiki.platform</groupId>
       <artifactId>xwiki-platform-job</artifactId>
       <version>9.0-SNAPSHOT</version>
     </parent>
     <packaging>webjar</packaging>
     <artifactId>xwiki-platform-job-webjar</artifactId>
    </projectr>
  • optionally register the extension so that webjar is recognized (not needed if you have platform pom >= 9.0 as parent):
    <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">
     <modelVersion>4.0.0</modelVersion>
     <parent>
       <groupId>org.xwiki.platform</groupId>
       <artifactId>xwiki-platform-job</artifactId>
       <version>9.0-SNAPSHOT</version>
     </parent>
     <packaging>webjar</packaging>
     <artifactId>xwiki-platform-job-webjar</artifactId>
     <build>
       <extensions>
         <!-- Needed to add support for the "webjar" packaging -->
         <extension>
           <groupId>org.xwiki.commons</groupId>
           <artifactId>xwiki-commons-tool-webjar-handlers</artifactId>
           <version>${commons.version}</version>
         </extension>
       </extensions>
     </build>
    </project>
Tags:
   

Get Connected