为了使用当前在我的uber-pom中运行的相同目标来调用Maven调用程序插件,我需要一种方法来将当前目标传递到调用程序插件的配置中。
像这样的
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
...
<configuration>
<goals>
<goal>${maven.goal}</goal>
</goals>
...发布于 2009-03-13 13:55:11
Maven Help plugin可能会帮助您get where you want to go。${reactorProjects}变量保存您正在查找的内容,但可能不是您希望重用它的确切格式。
您可以通过以下方式查看可用的all the expressions:
mvn help:expressions然后你就可以test one of them without the tedium of a pom via evaluation了
mvn help:evaluate这将把您带到一个提示,您可以使用它来尝试表达式。
如果我使用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>发布于 2017-02-16 00:02:23
我添加了以下依赖项:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.3</version>
</dependency>然后在我的魔力中:
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();https://stackoverflow.com/questions/642078
复制相似问题