Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ under the License.
</distributionManagement>

<properties>
<mavenVersion>3.6.3</mavenVersion>
<mavenVersion>3.8.1</mavenVersion>
<project.build.outputTimestamp>2021-02-24T19:52:25Z</project.build.outputTimestamp>
</properties>

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@

import java.io.File;

import org.apache.maven.execution.MavenSession;
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.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;

/**
* Evaluate the specified script or scriptFile
Expand Down Expand Up @@ -64,14 +68,30 @@ public class EvalMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject project;

@Parameter(defaultValue = "${mojoExecution}", readonly = true)
MojoExecution mojoExecution;

@Parameter(defaultValue = "${pluginDescriptor}", readonly = true)
private PluginDescriptor pluginDescriptor;

@Parameter(defaultValue = "${session}", readonly = true)
private MavenSession session;

@Parameter(defaultValue = "${settings}", readonly = true)
private Settings settings;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
AbstractScriptEvaluator execute = constructExecute();

Bindings bindings = new SimpleBindings();
bindings.put("session", session);
bindings.put("project", project);
bindings.put("pluginDescriptor", pluginDescriptor);
bindings.put("log", getLog());
bindings.put("mojoExecution", mojoExecution);
bindings.put("settings", settings);

Object result = execute.eval(bindings, getLog());

Expand Down
6 changes: 5 additions & 1 deletion src/site/markdown/script-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ under the License.

The following variables are available in the script context

* `org.apache.maven.execution.MavenSession session`
* `org.apache.maven.project.MavenProject project`
* `org.apache.maven.plugin.logging.Log log`
* `org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor`
* `org.apache.maven.plugin.logging.Log log`
* `org.apache.maven.plugin.MojoExecution mojoExecution`
* `org.apache.maven.settings.Settings settings`