Configuring Generation of Plugin Descriptor
To configure the generation of the plugin descriptor, add the following to the project's POM:
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-plugin</artifactId> <version>3.14.0</version> <configuration> <goalPrefix>plugin</goalPrefix> <outputDirectory>target/dir</outputDirectory> </configuration> </plugin> </plugins> ... </build> ... </project>
The goalPrefix
parameter will set the goal prefix for the plugin that is specified in the descriptor. The outputDirectory
parameter, on the other hand, specifies the target location of the generated plugin descriptor.
Example
For instance, if we make reference on MyMojo
from maven-my-plugin
which is generated by the Maven Archetype Plugin, i.e.:
mvn archetype:create \ -DgroupId=org.apache.maven.plugin.my \ -DartifactId=maven-my-plugin \ -DarchetypeArtifactId=maven-archetype-mojo
The plugin descriptor generated by mvn package
should be:
<plugin> <description></description> <groupId>org.apache.maven.plugin.my</groupId> <artifactId>maven-my-plugin</artifactId> <version>1.0-SNAPSHOT</version> <goalPrefix>my</goalPrefix> <isolatedRealm>false</isolatedRealm> <inheritedByDefault>true</inheritedByDefault> <mojos> <mojo> <goal>touch</goal> <description>Goal which touches a timestamp file.</description> <requiresDirectInvocation>false</requiresDirectInvocation> <requiresProject>true</requiresProject> <requiresReports>false</requiresReports> <aggregator>false</aggregator> <requiresOnline>false</requiresOnline> <inheritedByDefault>true</inheritedByDefault> <phase>process-sources</phase> <implementation>org.apache.maven.plugin.my.MyMojo</implementation> <language>java</language> <instantiationStrategy>per-lookup</instantiationStrategy> <executionStrategy>once-per-session</executionStrategy> <parameters> <parameter> <name>outputDirectory</name> <type>java.io.File</type> <required>true</required> <editable>true</editable> <description>Location of the file.</description> </parameter> </parameters> <configuration> <outputDirectory implementation="java.io.File">${project.build.directory}</outputDirectory> </configuration> </mojo> </mojos> <dependencies> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> <type>jar</type> <version>2.0</version> </dependency> </dependencies> </plugin>