Skip to content

Commit 69c653a

Browse files
elharoslawekjaranowski
authored andcommitted
Update document to use Guice constructor injection
* Update document to use Guice constructor injection * Update index.apt (cherry picked from commit 4a5fe6a)
1 parent 73f78dc commit 69c653a

File tree

1 file changed

+22
-22
lines changed
  • maven-plugin-tools-annotations/src/site/apt

1 file changed

+22
-22
lines changed

maven-plugin-tools-annotations/src/site/apt/index.apt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,6 @@ public class MyMojo
9090
required = <false|true> )
9191
private String parameter;
9292

93-
@Component( role = MyComponentExtension.class,
94-
hint = "..." )
95-
private MyComponent component;
96-
97-
// pseudo-parameters (marked read-only) permitting injection of Maven build context objects
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
102-
103-
// @Parameter( defaultValue = "${session}", readonly = true )
104-
@Component // since Maven 3.2.5, thanks to MNG-5695
105-
private MavenSession session;
106-
107-
// @Parameter( defaultValue = "${project}", readonly = true )
108-
@Component // since Maven 3.2.5, thanks to MNG-5695
109-
private MavenProject project;
110-
111-
// @Parameter( defaultValue = "${mojoExecution}", readonly = true )
112-
@Component // since Maven 3.2.5, thanks to MNG-5695
113-
private MojoExecution mojoExecution;
114-
11593
@Parameter( defaultValue = "${reactorProjects}", readonly = true )
11694
// prefer using session.getProjects()
11795
private List<MavenProject> reactorProjects;
@@ -132,6 +110,28 @@ public class MyMojo
132110
// prefer using project.getBuild().getDirectory()
133111
private File target;
134112

113+
// pseudo-parameters (marked read-only) permitting injection of Maven build context objects
114+
// sample objects taken from Maven API through PluginParameterExpressionEvaluator
115+
// https://maven.apache.org/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html
116+
// plugins targeting Maven 3.2.5+ (after MNG-5695) should not use these pseudo-parameters any more,
117+
// but @Inject and Maven APIs to get better compiler-time checks
118+
119+
private final MyComponent component;
120+
121+
private final MavenSession session;
122+
123+
private final MavenProject project;
124+
125+
private final MojoExecution mojoExecution;
126+
127+
@Inject
128+
public MyMojo(MyComponent component, MavenSession session, MavenProject project, MojoExecution mojoExecution) {
129+
this.component = component;
130+
this.session = session;
131+
this.project = project;
132+
this.mojoExecution = mojoExecution;
133+
}
134+
135135
/**
136136
* @Parameter for methods can be used only with public setter methods
137137
*/

0 commit comments

Comments
 (0)