我正在开发一个 Maven 插件,其目标是具有类参数。
我想配置这个目标以使用特殊的类。
这是我的 Maven 插件 Mojo:
/**
* The used parser.
*
* @parameter expression="${parser}"
*/
private EndpointParser parser;
public void execute() throws MojoExecutionException {
这是我使用该插件的项目的 pom.xml:
...
<plugins>
<plugin>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<configuration>
<parser>com.foo.bar.MyEndpointParser</parser>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
...
如何让它工作。
最佳答案
如果MyEndPointParser
不是您的插件的一部分,而是另一个项目的一部分(它本身不是您的插件的依赖项),您必须将其声明为不是您的项目的依赖项,而是您的插件的依赖项,例如
<plugins>
<plugin>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<configuration>
<parser>com.foo.bar.MyEndpointParser</parser>
</configuration>
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>contains-my-endpoint-parser</artifactId>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
关于java - Maven 插件配置将参数设置为类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25566681/