Is there a variable in Maven that supports the current target?

To call the Maven invoker plugin for the same purpose that is currently running in my uber-pom, I need a way to pass the current target into the invoker-plugin configuration.

Something like org.apache.maven.plugins Maven-Caller-plugin ... $ {Maven.gaol} ...

+3
source share
2 answers

The Maven Support Plugin can help you get where you want to go . The variable $ {reactorProjects} contains what you are looking for, but maybe not in the format in which you intend to reuse it.

:

mvn help:expressions

:

mvn help:evaluate

, , .

: ${reactorProjects}, , , :

<plugins>
  <plugin>
    <inheritanceApplied>true</inheritanceApplied>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-help-plugin</artifactId>
    <version>2.1</version>
    <extensions>false</extensions>
    <dependencies/>
  </plugin>
</plugins>
<pluginMap class="linked-hash-map">
  <entry>
    <string>org.apache.maven.plugins:maven-help-plugin</string>
    <plugin reference="../../../plugins/plugin"/>
  </entry>
</pluginMap>
+1

:

<dependency>
  <groupId>org.apache.maven</groupId>
  <artifactId>maven-core</artifactId>
  <version>3.0.3</version>
</dependency>

MOJO:

import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
...
@Parameter(defaultValue = "${session}", readonly = true)
private MavenSession session;

, :

MavenExecutionRequest executionRequest = session.getRequest();
List<String> goals = executionRequest.getGoals();
0

Source: https://habr.com/ru/post/1704713/


All Articles