-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathusing-annotations.apt.vm
More file actions
120 lines (96 loc) · 4.19 KB
/
Copy pathusing-annotations.apt.vm
File metadata and controls
120 lines (96 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
------
Using Plugin Tools Java5 Annotations
------
Olivier Lamy
------
2012-05-14
------
~~ 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:
~~ https://maven.apache.org/doxia/references/apt-format.html
Using Plugin Tools Java Annotations
You can use Java annotations to generate the plugin descriptor file.
<<NOTE>> With annotations, your Mojo super class does not have to be in the same project: provided that the superclass also uses annotations, it
can now come from reactor projects or external dependencies. By default all dependencies are scanned, but this can be reduced with the <<<mojoDependencies>>>
parameter. BUT as javadoc doclets are still useful for goals and parameters description, <<<@since>>> and <<<@deprecated>>>, the sources are still scanned. So if you use an external
dependency, you must still provide an artifact with sources (<<<sources>>> classifier) to provide documentation (the tooling will skip error if this artifact
sources is missing).
* Annotations
Information for plugin descriptor generation is specified using 4 annotations:
* 2 class level annotations:
* <<<@Mojo>>>: This annotation will mark your class as a Mojo,
* <<<@Execute>>>: Used if your Mojo needs to fork a lifecycle,
[]
* 1 field or method level annotations:
* <<<@Parameter>>>: Used to configure your Mojo parameters,
[]
* 1 field level annotations:
* <<<@Component>>>: Used to configure injection of Plexus components or Maven context components.
[]
[]
For more information on these annotations, see the
{{{../../maven-plugin-tools-annotations/index.html#Supported_Annotations}corresponding documentation}}.
Notice that Plugin Tools Java Annotations are named after Plugin Tools Javadoc Tags
with following little differences:
*-------------------------------+---------------+
|| {{{../../maven-plugin-tools-java/index.html}Plugin Tools Javadoc Tags}} || {{{../../maven-plugin-tools-annotations/index.html}Plugin Tools Java Annotation}} ||
*-------------------------------+---------------+
| <<<@goal "goal-name">>> | <<<@Mojo( name = "goal-name" )>>>
*-------------------------------+---------------+
| <<<@phase "\<phase-name\>">>> | <<<@Mojo( defaultPhase = LifecyclePhase.\<phase\> )>>>
*-------------------------------+---------------+
* POM configuration
To use these Java annotations, add a dependency on
<<<maven-plugin-annotations>>> to your pom, preferably with <<<provided>>> scope.
+-----+
<project>
...
<packaging>maven-plugin</packaging>
...
<dependencies>
<!-- dependencies to annotations -->
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${project.version}</version>
<scope>provided</scope> <!-- annotations are not used at runtime because @Retention(value=CLASS), they are needed only to build the plugin -->
</dependency>
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>${project.version}</version>
<executions>
<!-- if you want to generate help goal -->
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
...
</project>
+-----+