| ------ |
| Configuring Generation of Plugin Descriptor |
| ------ |
| Maria Odea Ching |
| ------ |
| 2008-02-01 |
| ------ |
| |
| ~~ Licensed to the Apache Software Foundation (ASF) under one |
| ~~ or more contributor license agreements. See the NOTICE file |
| ~~ distributed with this work for additional information |
| ~~ regarding copyright ownership. The ASF licenses this file |
| ~~ to you under the Apache License, Version 2.0 (the |
| ~~ "License"); you may not use this file except in compliance |
| ~~ with the License. You may obtain a copy of the License at |
| ~~ |
| ~~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~~ |
| ~~ Unless required by applicable law or agreed to in writing, |
| ~~ software distributed under the License is distributed on an |
| ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ~~ KIND, either express or implied. See the License for the |
| ~~ specific language governing permissions and limitations |
| ~~ under the License. |
| |
| ~~ NOTE: For help with the syntax of this file, see: |
| ~~ http://maven.apache.org/doxia/references/apt-format.html |
| |
| 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>${project.version}</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> |
| ----- |