3

I'm writing my own Maven plugin. My Mojo has a required parameter list:

@Parameter(property = "map.packages", required = true)
private List<String> packages;

Now, when I run this plugin in a project with no configuration, I would expect the build to fail as the packages parameter is required. Instead I get packages as an empty list.

Is this a bug or am I doing something wrong?

Ps. I probably should have added this to some issue tracker but where is Maven's issue tracker?

4

2 回答 2

1

问题的定位基于可以通过调试输出(在集成测试的帮助下)观察到的属性,如下所示:

[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal:          com.nitorcreations:drm-maven-plugin:1.1-SNAPSHOT:map (test-parameter)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <outputDirectory default-value="${project.build.directory}">${outputDir}</outputDirectory>
  <packages>${map.packages}</packages>
  <project default-value="${project}"/>
</configuration>

在这里您可以看到属性 (map.packages) 将被注入到包配置参数中,这意味着配置参数具有满足所需参数的值。如果您需要结合 required 定义属性,则需要检查 execute() 方法。

于 2013-11-10T18:12:14.897 回答
-1

根据此文档http://maven.apache.org/developers/mojo-api-specification.html#The_Descriptor_and_Annotations您可以尝试使用 @Required 注释

于 2013-11-08T09:40:38.153 回答