【问题标题】:How to define @Parameter annotation in Maven POM如何在 Maven POM 中定义 @Parameter 注解
【发布时间】:2014-04-26 21:32:36
【问题描述】:

我写了一个Mojo Plugin,设置了两个@Parameter(import org.apache.maven.plugins.annotations.Parameter;)

我想在我想使用这个插件的项目的 POM 中配置参数。

无论我每次在哪里收到错误消息。

POM 部分:

        <plugin>
            <groupId>com.tup.test</groupId>
            <artifactId>versionsextra</artifactId>
            <version>1.0-SNAPSHOT</version>
            <executions>
                <execution>
                    <id>path</id>
                    <phase>test</phase>
                    <configuration>
                        <path>${basedir}/src/main/resources/configsys/dev/etc/deploy_env</path>

                    </configuration>

                </execution>
            </executions>

所以其中一个参数被称为路径:

 @Parameter()

private String path;

【问题讨论】:

  • 你得到什么错误信息?

标签: maven parameters mojo


【解决方案1】:

好的,我明白了。

我必须这样声明:

@Mojo(name="devversion")

public class ParameterMojo extends AbstractMojo {

@Parameter()
private String path;

@Parameter()
private String pathsave;

...

在 POM 中:

      <plugin>
            <groupId>com.tup.test</groupId>
            <artifactId>versionsextra</artifactId>
            <version>1.0-SNAPSHOT</version>
            <executions>
                <execution>
                    <id>testen</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>devversion</goal>
                    </goals>
                    <configuration>
                        <path>${basedir}/src/main/resources/configsys/dev/etc/deploy_env</path>
                        <pathsave>${basedir}/src/main/resources/configsys/dev/etc/test.txt</pathsave>
                    </configuration>
                </execution>                        
            </executions>
        </plugin>

【讨论】:

  • 因为这个方案在代码中添加了注解,所以还要在POM中添加工件maven-plugin-annotations
猜你喜欢
  • 1970-01-01
  • 2015-05-20
  • 1970-01-01
  • 2012-07-15
  • 2011-12-05
  • 2011-06-17
  • 1970-01-01
  • 2012-01-31
  • 2019-11-25
相关资源
最近更新 更多