You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2024/12/23 16:35:05 UTC
(maven-plugin-tools) branch master updated: Update document to use Guice constructor injection (#345)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
The following commit(s) were added to refs/heads/master by this push:
new 4a5fe6a8 Update document to use Guice constructor injection (#345)
4a5fe6a8 is described below
commit 4a5fe6a81c9f88583ad8dbd75c42d93bb9c6b1bd
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Mon Dec 23 16:34:59 2024 +0000
Update document to use Guice constructor injection (#345)
* Update document to use Guice constructor injection
* Update index.apt
---
.../src/site/apt/index.apt | 44 +++++++++++-----------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/maven-plugin-tools-annotations/src/site/apt/index.apt b/maven-plugin-tools-annotations/src/site/apt/index.apt
index dad471df..666af0ac 100644
--- a/maven-plugin-tools-annotations/src/site/apt/index.apt
+++ b/maven-plugin-tools-annotations/src/site/apt/index.apt
@@ -90,28 +90,6 @@ public class MyMojo
required = <false|true> )
private String parameter;
- @Component( role = MyComponentExtension.class,
- hint = "..." )
- private MyComponent component;
-
- // pseudo-parameters (marked read-only) permitting injection of Maven build context objects
- // sample objects taken from Maven API through PluginParameterExpressionEvaluator
- // https://maven.apache.org/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html
- // plugins targetting Maven 3.2.5+ (after MNG-5695) should not use these pseudo-parameters any more,
- // but @Component and Maven APIs to get better compiler-time checks
-
- // @Parameter( defaultValue = "${session}", readonly = true )
- @Component // since Maven 3.2.5, thanks to MNG-5695
- private MavenSession session;
-
- // @Parameter( defaultValue = "${project}", readonly = true )
- @Component // since Maven 3.2.5, thanks to MNG-5695
- private MavenProject project;
-
- // @Parameter( defaultValue = "${mojoExecution}", readonly = true )
- @Component // since Maven 3.2.5, thanks to MNG-5695
- private MojoExecution mojoExecution;
-
@Parameter( defaultValue = "${reactorProjects}", readonly = true )
// prefer using session.getProjects()
private List<MavenProject> reactorProjects;
@@ -132,6 +110,28 @@ public class MyMojo
// prefer using project.getBuild().getDirectory()
private File target;
+ // pseudo-parameters (marked read-only) permitting injection of Maven build context objects
+ // sample objects taken from Maven API through PluginParameterExpressionEvaluator
+ // https://maven.apache.org/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html
+ // plugins targeting Maven 3.2.5+ (after MNG-5695) should not use these pseudo-parameters any more,
+ // but @Inject and Maven APIs to get better compiler-time checks
+
+ private final MyComponent component;
+
+ private final MavenSession session;
+
+ private final MavenProject project;
+
+ private final MojoExecution mojoExecution;
+
+ @Inject
+ public MyMojo(MyComponent component, MavenSession session, MavenProject project, MojoExecution mojoExecution) {
+ this.component = component;
+ this.session = session;
+ this.project = project;
+ this.mojoExecution = mojoExecution;
+ }
+
/**
* @Parameter for methods can be used only with public setter methods
*/