Flavor API

Last modified by Admin on 2024/10/09 01:23

lorryAPI to get flavors from the repositories.
TypeJAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Installable with the Extension Manager

Description

XWiki offers different Flavors. A Flavor is a collection of applications. When you install a Flavor, you get a wiki fully configured for a use-case.

This system is mostly visible since XWiki 9.5 which strongly rely on it.

Flavor picker

In some places, you will see the Flavor picker, which is designed to make you chose a Flavor between the extensions available in your repositories. Since 8.1 flavors are also searched in local repository.

flavor-picker.png

Valid flavors

Since 8.0 the Flavor picker won't display all flavors found on various repositories right away. Instead it starts a background job which validate each flavor and find the right version for your distribution. You will see a progress bar and the valid flavor will be automatically added once found.

Known flavors

Since 8.1 it's possible for a distribution to indicate known flavors, which means flavors id and version known to be valid with this distribution. Its usually flavors in sync with the distribution itself or well known like XWiki Flavor or XWiki Enterprise Flavors.

In a Maven project it must be indicated the pom.xml of the distribution package (or its parent) the following way:

  <properties>
   <!-- Flavors known to be valid with the current distribution -->
   <xwiki.extension.knownFlavors>
        org.xwiki.platform:xwiki-platform-distribution-flavor/${project.version},
        org.xwiki.enterprise:xwiki-enterprise-ui-mainwiki/${project.version},
        org.xwiki.enterprise:xwiki-enterprise-ui-wiki/${project.version}
   </xwiki.extension.knownFlavors>
 </properties>

Known invalid flavors

Since 9.5 it's possible for a distribution to indicate known invalid flavors, which means flavors id known to be invalid with this distribution (a good example is XWiki Enterprise which are invalid in 9.5+).

In a Maven project it must be indicated the pom.xml of the distribution package (or its parent) the following way:

  <properties>
   <!-- Flavors known to be valid with the current distribution -->
   <xwiki.extension.knownInvalidFlavors>
        org.xwiki.enterprise:xwiki-enterprise-ui-mainwiki,
        org.xwiki.enterprise:xwiki-enterprise-ui-wiki
   </xwiki.extension.knownInvalidFlavors>
 </properties>

How to create a Flavor

This part is technical and designed for technical users.

Technically, a Flavor is nothing but a simple Extension with category flavor (as in <xwiki.extension.category>flavor</xwiki.extension.category> in Maven), which depends on other Extensions.

Usually it's a XAR (but it does not have to) with a few Flavor specific pages like the home page and dependencies on various applications.

You might be interested by creating a project in the XWiki Contrib space.

Here is an example of a Flavor, built with Maven:

<?xml version="1.0" encoding="UTF-8"?>
<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.commons</groupId>
   <artifactId>xwiki-commons-pom</artifactId>
   <version>7.1-milestone-2</version>
 </parent>
 <groupid>org.xwiki.contrib</groupid>
 <artifactId>my-flavor</artifactId>
 <name>My Flavor</name>
 <packaging>xar</packaging>
 <description>Description of my Flavor</description>
 <properties>
   <!-- Important property to be referenced as a Flavor in the XWiki repository! -->
   <xwiki.extension.category>flavor</xwiki.extension.category>
 </properties>
 <dependencies>
   <!-- The Flavor is based on the standard ui for subwikis -->
   <dependency>
     <groupId>org.xwiki.enterprise</groupId>
     <artifactId>xwiki-enterprise-ui-wiki</artifactId>
     <version>${commons.version}</version>
     <type>xar</type>
     <scope>runtime</scope>
   </dependency>
   <!-- We want the PDFViewer macro in the Flavor -->
   <dependency>
     <groupId>org.xwiki.contrib</groupId>
     <artifactId>xwiki-macro-pdfviewer</artifactId>
     <version>1.4</version>
     <type>xar</type>
     <scope>runtime</scope>
   </dependency>
   <!-- We want the file manager in the Flavor -->
   <dependency>
     <groupId>org.xwiki.contrib</groupId>
     <artifactId>application-filemanager-ui</artifactId>
     <version>2.0-rc-1</version>
     <type>xar</type>
     <scope>runtime</scope>
   </dependency>
 </dependencies>
 <build>
   <!-- Needed to add support for the XAR packaging -->
   <extensions>
     <extension>
       <groupId>org.xwiki.commons</groupId>
       <artifactId>xwiki-commons-tool-xar-handlers</artifactId>
       <version>${commons.version}</version>
     </extension>
   </extensions>
   <plugins>
     <!-- The XAR packaging uses the XAR plugin and thus we need to define what version to use -->
     <plugin>
       <groupId>org.xwiki.commons</groupId>
       <artifactId>xwiki-commons-tool-xar-plugin</artifactId>
       <version>${commons.version}</version>
     </plugin>
   </plugins>
 </build>
</project>

Testing

To test a flavor you're developing follow these steps:

  • Build the flavor: mvn clean install
  • Edit the META-INF/extension.xed file inside the XWiki WAR you're testing with and add your flavor id and version to the list
      of known flavors. Note that this is a hack since normally the canonical way would be to deploy the flavor in a
      searchable XWiki Extensions Repository but that's a lot more complex and time-consuming.
  • Modify the <xwiki.extension.knownFlavors> tag to add the flavor id and version. For example if you wish to test the org.xwiki.contrib:flavor-demo/1.1-SNAPSHOT flavor:
      <xwiki.extension.knownFlavors>
        org.xwiki.platform:xwiki-platform-distribution-flavor-mainwiki/11.10,
        org.xwiki.platform:xwiki-platform-distribution-flavor-wiki/11.10,
        org.xwiki.contrib:flavor-demo/1.1-SNAPSHOT</xwiki.extension.knownFlavors>
  • Add your local Maven repository as an Extension repository in the XWiki instance.
  • Start or restart XWiki.

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

Dependencies

Dependencies for this extension (org.xwiki.platform:xwiki-platform-flavor-api 16.8.0):

Get Connected