@@ -85,7 +85,7 @@ public class MyMojo
85
85
@Parameter( name = "parameter",
86
86
alias = "myAlias",
87
87
property = "a.property",
88
- defaultValue = "an expression, possibly with ${variables}",
88
+ defaultValue = "an expression, possibly with ${variables} and pseudo-parameter expressions ${project.xxx.yyy} ",
89
89
readonly = <false|true>,
90
90
required = <false|true> )
91
91
private String parameter;
@@ -94,27 +94,42 @@ public class MyMojo
94
94
hint = "..." )
95
95
private MyComponent component;
96
96
97
+ // pseudo-parameters (marked read-only) permitting injection of Maven build context objects
97
98
// sample objects taken from Maven API through PluginParameterExpressionEvaluator
99
+ // https://maven.apache.org/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html
100
+ // plugins targetting Maven 3.2.5+ (after MNG-5695) should not use these pseudo-parameters any more,
101
+ // but @Component and Maven APIs to get better compiler-time checks
98
102
99
- @Parameter( defaultValue = "${session}", readonly = true )
103
+ // @Parameter( defaultValue = "${session}", readonly = true )
104
+ @Component // since Maven 3.2.5, thanks to MNG-5695
100
105
private MavenSession session;
101
106
102
- @Parameter( defaultValue = "${project}", readonly = true )
107
+ // @Parameter( defaultValue = "${project}", readonly = true )
108
+ @Component // since Maven 3.2.5, thanks to MNG-5695
103
109
private MavenProject project;
104
110
105
- @Parameter( defaultValue = "${mojoExecution}", readonly = true )
106
- private MojoExecution mojo;
111
+ // @Parameter( defaultValue = "${mojoExecution}", readonly = true )
112
+ @Component // since Maven 3.2.5, thanks to MNG-5695
113
+ private MojoExecution mojoExecution;
114
+
115
+ @Parameter( defaultValue = "${reactorProjects}", readonly = true )
116
+ // prefer using session.getProjects()
117
+ private List<MavenProject> reactorProjects;
107
118
108
119
@Parameter( defaultValue = "${plugin}", readonly = true ) // Maven 3 only
120
+ // prefer using mojoExecution.getMojoDescriptor()
109
121
private PluginDescriptor plugin;
110
122
111
123
@Parameter( defaultValue = "${settings}", readonly = true )
124
+ // prefer using session.getSettings()
112
125
private Settings settings;
113
126
114
127
@Parameter( defaultValue = "${project.basedir}", readonly = true )
128
+ // prefer using project.getBasedir()
115
129
private File basedir;
116
130
117
131
@Parameter( defaultValue = "${project.build.directory}", readonly = true )
132
+ // prefer using project.getBuild().getDirectory()
118
133
private File target;
119
134
120
135
/**
@@ -144,3 +159,10 @@ public class MyMojo
144
159
145
160
* {{{/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html}PluginParameterExpressionEvaluator}},
146
161
used to evaluate plugin parameters values during Mojo configuration,
162
+
163
+ * pseudo parameters:
164
+
165
+ * <<<PluginParameterExpressionEvaluator>>> {{{https://maven.apache.org/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html}javadoc}} /
166
+ {{{https://maven.apache.org/ref/current/maven-core/xref/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html}source}}
167
+
168
+ * {{{https://issues.apache.org/jira/browse/MNG-5695}MNG-5695}}: scoped objects added to Guice/Sisu in {{{https://maven.apache.org/ref/current/maven-core/}maven-core}} 3.2.5
0 commit comments