From 36f3aae5e980aeee260c0a3e15057813017ac8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20Kartal?= Date: Wed, 27 May 2026 15:03:19 +0200 Subject: [PATCH] Enhanced script context by MojoExecution --- pom.xml | 2 +- .../java/org/apache/maven/plugins/scripting/EvalMojo.java | 5 +++++ src/site/markdown/script-context.md | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a40d7f8..cc90013 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 47 + 48 diff --git a/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java b/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java index 43f9f22..2d94f88 100644 --- a/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java +++ b/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java @@ -25,6 +25,7 @@ import java.io.File; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -64,6 +65,9 @@ public class EvalMojo extends AbstractMojo { @Parameter(defaultValue = "${project}", readonly = true) private MavenProject project; + @Parameter(defaultValue = "${mojoExecution}", readonly = true) + MojoExecution mojoExecution; + @Override public void execute() throws MojoExecutionException, MojoFailureException { try { @@ -72,6 +76,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { Bindings bindings = new SimpleBindings(); bindings.put("project", project); bindings.put("log", getLog()); + bindings.put("mojoExecution", mojoExecution); Object result = execute.eval(bindings, getLog()); diff --git a/src/site/markdown/script-context.md b/src/site/markdown/script-context.md index 03ed850..7235154 100644 --- a/src/site/markdown/script-context.md +++ b/src/site/markdown/script-context.md @@ -21,4 +21,5 @@ under the License. The following variables are available in the script context * `org.apache.maven.project.MavenProject project` - * `org.apache.maven.plugin.logging.Log log` \ No newline at end of file + * `org.apache.maven.plugin.logging.Log log` + * `org.apache.maven.plugin.MojoExecution mojoExecution` \ No newline at end of file