XWiki Contrib - Managed Dependencies Maven Plugin

Last modified by Anca Luca on 2024/07/05 17:47

cogA plugin that allows to inject managed dependencies from a given set of sources.
TypeJAR
CategoryOther
Developed by

Clément Aubin

Rating
1 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

A plugin that allows to inject managed dependencies from a given set of sources.

This plugin will collect dependencies from a given set of artifacts, filter these dependencies based on their group ID and include them as managed dependencies of the project.

The plugin comes with sensible defaults to make it usable as part of the development of XWiki Contrib extensions.

Even though this plugin will help solve some issues related to managed dependencies, some enforcer rules may still fail, because they don't depend directly on the version of a specific dependency.

Below are the list of known enforcer rules that can fail despite using this plugin :

  • enforce-no-old-xwiki-platform in XWiki Platform

Usage

To use the plugin in its default configuration, add the following in the build section of your project parent POM :

  <build>
   <plugins>
     <plugin>
       <groupId>org.xwiki.contrib</groupId>
       <artifactId>managed-dependencies-maven-plugin</artifactId>
       <version>1.0</version>
       <executions>
         <execution>
           <goals>
             <goal>inject-managed-dependencies</goal>
           </goals>
         </execution>
       </executions>
     </plugin>
     <!-- The configuration of the enforcer plugin will be inherited from parent POMs, but we need to refer
      to this plugin here in order to make sure that the inject-managed-dependencies mojo is executed before
      the enforcer -->

     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-enforcer-plugin</artifactId>
     </plugin>
   </plugins>
 </build>

By default, this configuration will :

  • Resolve the dependencies of the two following artifacts :
    • org.xwiki.platform:xwiki-platform-distribution-war-dependencies/${platform.version}
    • org.xwiki.platform:xwiki-platform-distribution-flavor-common/${platform.version}
  • From the dependencies of these artifacts, add each dependency who have a group ID corresponding to one in the following list to the project managed dependencies :
    • org.xwiki.platform
    • org.xwiki.rendering
    • org.xwiki.commons

Configuration

The plugin provides the following configuration options :

NameSinceDescriptionMandatoryDefault value
managedDependencySources1.0

A list of group IDs that should be used to retain artifacts that will be added as managed dependencies.

Example usage :

<managedDependencySources>
 <managedDependencySource>
   <groupId>org.xwiki.platform</groupId>
   <artifactId>xwiki-platform-distribution-war-dependencies</artifactId>
   <version>${platform.version}</version>
   <type>pom</type>
 </managedDependencySource>
 <managedDependencySource>
   <groupId>org.xwiki.platform</groupId>
   <artifactId>xwiki-platform-distribution-flavor-common</artifactId>
   <version>${platform.version}</version>
   <type>pom</type>
 </managedDependencySource>
</managedDependencySources>
No
  • org.xwiki.platform:xwiki-platform-distribution-war-dependencies/${platform.version}
  • org.xwiki.platform:xwiki-platform-distribution-flavor-common/${platform.version}
xwikiPlatformVersion1.0The version of XWiki platform to use when using the default managed dependency sourcesNo${platform.version}
useXWikiWARDependencies1.0Whether the artifact org.xwiki.platform:xwiki-platform-distribution-war-dependencies should be used as a managed dependency source (only used when no managed dependency sources is defined in the configuration)Notrue
useXWikiStandardFlavorDependencies1.0Whether the artifact org.xwiki.platform:xwiki-platform-distribution-flavor-common should be used as a managed dependency source (only used when no managed dependency sources is defined in the configuration)Notrue
dependencyGroupIDFilters1.0

A list of group IDs that should be used to retain artifacts that will be added as managed dependencies.

Example usage :

<dependencyGroupIDFilters>
 <dependencyGroupIDFilter>org.xwiki.platform</dependencyGroupIDFilter>
 <dependencyGroupIDFilter>org.xwiki.rendering</dependencyGroupIDFilter>
 <dependencyGroupIDFilter>org.xwiki.commons</dependencyGroupIDFilter>
</dependencyGroupIDFilters>
No
  • org.xwiki.platform
  • org.xwiki.rendering
  • org.xwiki.commons

FAQ

How to check the dependency tree?

Having the managed dependencies setup done by a plugin and not directly in the pom will have an impact over the computation of the dependency tree by the maven dependency plugin. Sometimes you may need to see the dependency tree of your module including all the dependencies managed by this plugin.
For this, you can use the following maven command:

mvn org.xwiki.contrib:managed-dependencies-maven-plugin:inject-managed-dependencies dependency:tree

Dependencies

Dependencies for this extension (org.xwiki.contrib:managed-dependencies-maven-plugin 1.0):

  • org.apache.maven.shared:maven-artifact-transfer 0.13.1

Get Connected