Maven extension to add dependencies and repositories specified in Grape @Grab
/@GrabResolver
annotations.
This extension will activate implicitly once configured. It will scan the source
recursively for *.groovy
files and locate any @Grab
annotations (i.e. @Grab
and @GrabResolver
). These will be parsed and the
resulting dependencies and repositories added to the Maven project dependencies.
It is recommended to install this as a Core Extension (See here). Further details on this extension method may be found in Using Maven 3 lifecycle extension and Maven 3.3.1 Release Notes
A typical extension file is:
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>org.goots.maven.extensions</groupId>
<artifactId>grab-dependency-populator</artifactId>
<version>1.0</version>
</extension>
</extensions>
It may also be installed in <maven-installation>/lib/ext
using the jar-with-dependencies
version.
The following configuration options are available:
Config Property | Default | Description |
---|---|---|
grabPopulatorDisable |
false | Disables the extension |
grabPopulatorAddAtEnd |
true | Add the 'grabbed' dependencies at the end of the list |
grabPopulatorErrorOnMismatch |
true | Throws an error if multiple @Grab have the same groupId / artifactId but differing versions |
grabPopulatorVerifyDependencies |
true | Checks that all no grabbed dependency has a different version to native dependencies |
The extension can be configured in two different ways:
An xml file, named as grabDependencyPopulator.xml
may be placed within <project>/.mvn
. It may contain:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<errorOnMismatch>true</errorOnMismatch>
<verifyDependencies>false</verifyDependencies>
<atEnd>false</atEnd>
<include>
<directory>src</directory>
<directory>vars</directory>
</include>
</configuration>
The 'include/directory' denotes a list of directories the extension will start searching from. If it is not included then the tool will search all directories from the root (excluding target
build directories).
The extension will also check system properties (using the naming in the table above) that are available within Maven.