jahia v8 modules

Make a module compatible with both Jahia 81x and Jahia 82x

Question

Jahia 8.2 introduces newer versions of libraries you might be using in your modules. If you are in this situation, it remains possible to make your module compatible with both Jahia 8.1x and Jahia 8.2x by extending version compatibility in your import-packages.

The following dependencies are concerned by this knowledge base:

  • GraphQL-java upgraded from 13.0 to 21.3
  • graphql-dxm-provider upgraded to 3.0.0
  • Dom4j upgraded from 1.6.1 to 2.1.4
  • JDom upgraded from 1.1.3 to JDom2 (2.0.6.1)
  • Apache Tika has been upgraded from 1.28.5 to 2.9.1
  • Googla Guava

It is worth noting that in some cases, maintaining compatibility for the same module release with both Jahia versions is not possible, the most common case being a dependency on an API/bundle only available with Jahia 8.2.0.0. 

As part of the update to your codebase, please ensure your dependencies are explicitly declared, for example:

[...]
<dependencies>
    <dependency>
        <groupId>org.jahia.modules</groupId>
        <artifactId>graphql-dxm-provider</artifactId>
        <version>2.8.0</version>
        <scope>provided</scope>
    </dependency>
    [...]
<dependencies>
[...]

Solution

Jahia plugin

Although not mandatory, it is recommended to update jahia.plugin version to 6.9

Sample pom.xml update:

[...]
<properties>
    [...]
    <jahia.plugin.version>6.9</jahia.plugin.version>
    <import-package>
        org.jahia.modules.graphql.provider.dxm.admin;version="[2.8,4)",
        org.jahia.modules.graphql.provider.dxm.node;version="[2.8,4)",
    </import-package>
</properties>
[...]

GraphQL-java v21

GraphQL dependencies have been updated to the following versions:

  • Graphql-java v21.3
  • Graphql-java-servlet v15.1.1-jahia
  • Graphql-java-annotations v21.1

Performing such changes is only necessary if your module codebase explicitly depends on graphql-java. 
In most cases, it should have no impact on your code and should be limited to updating your pom.xml.

Sample pom.xml update:

[...]
<properties>
    [...]
    <jahia.plugin.version>6.9</jahia.plugin.version>
    <import-package>
        graphql.annotations.annotationTypes;version="[7.2,99)",
        graphql.annotations.connection;version="[7.2,99)",
        graphql.language;version="[13.0,22)",
        graphql.schema;version="[13.0,22)",
        graphql;version="[13.0,22)",
    </import-package>
</properties>
[...]
Note: the import-package specified above is an example, and should be adapted to imports your codebase is using/needing.
 

Graphql-dxm-provider 3.0.0

Sample pom.xml update:

[...]
<properties>
    [...]
    <jahia.plugin.version>6.9</jahia.plugin.version>
    <import-package>
        org.jahia.modules.graphql.provider.dxm;version="[2.8,4)",
        org.jahia.modules.graphql.provider.dxm.util;version="[2.8,4)",
        org.jahia.modules.graphql.provider.dxm.admin;version="[2.8,4)",
        org.jahia.modules.graphql.provider.dxm.osgi.annotations;version="[2.8,4)
    </import-package>
</properties>
[...]
Note: the import-package specified above is an example, and should be adapted to imports your codebase is using/needing.
 
For reference, our sitemap module (codebase), compatible with both Jahia 8.1x and Jahia 8.2x was updated to be compatible with two major versions of graphql-dxm-provider.

JDOM2

For JDOM, when it comes to being compatible with both Jahia 8.1 and Jahia 8.2+, the recommended approach is to proceed with the upgrade of your codebase to jdom2 and its declaration in the dependencies section of your pom.xml

Sample pom.xml update:

<dependency>
    <groupId>org.jdom</groupId>
    <artifactId>jdom2</artifactId>
    <version>2.0.6.1</version>
</dependency>
Note: the import-package specified above is an example, and should be adapted to imports your codebase is using/needing.

DOM4J

Sample pom.xml update:

[...]
<properties>
    [...]
    <jahia.plugin.version>6.9</jahia.plugin.version>
    <import-package>
        org.dom4j;version="[1.6,3)",
    </import-package>
</properties>
[...]
Note: the import-package specified above is an example, and should be adapted to imports your codebase is using/needing.
 

Apache Tika 2.9.1

Sample pom.xml update:

[...]
<properties>
    [...]
    <jahia.plugin.version>6.9</jahia.plugin.version>
    <import-package>
        org.apache.tika.parser;version="[1.28,3)"
    </import-package>
</properties>
[...]
Note: the import-package specified above is an example, and should be adapted to imports your codebase is using/needing.

Google Guava 33.0

Option 1

Sample pom.xml update:

[...]
<properties>
    [...]
    <jahia.plugin.version>6.9</jahia.plugin.version>
    <import-package>
        com.google.common.base;version="[30.1,34)",
    </import-package>
</properties>
[...]
Note: the import-package specified above is an example, and should be adapted to imports your codebase is using/needing.

Option 2

New APIs/methods introduced with JDK11 and above can be used to replace Google Guava entirely, often with limited effort.

Our sitemap module was using Google Guava in a very small portion of its code, and its entire removal was trivial (see commit).