简体   繁体   English

Maven插件需要参数

[英]Maven plugin required parameter

I'm writing my own Maven plugin. 我正在编写自己的Maven插件。 My Mojo has a required parameter list: 我的Mojo有一个必需的参数列表:

@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. 现在,当我在没有配置的项目中运行此插件时,我希望构建失败,因为需要packages参数。 Instead I get packages as an empty list. 相反,我将packages作为空列表。

Is this a bug or am I doing something wrong? 这是一个错误还是我做错了什么?

Ps. PS。 I probably should have added this to some issue tracker but where is Maven's issue tracker? 我可能应该将此添加到某个问题跟踪器,但Maven的问题跟踪器在哪里?

The problem is located based on the property which can be observed via a debug output (with the help of an integration test) which looks like this: 问题的位置基于可以通过调试输出(在集成测试的帮助下)观察到的属性,如下所示:

[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>

Here you can see that the property (map.packages) will be injected into the package configuration parameter which means the configuration parameter has a value which fulfills the required parameter. 在这里,您可以看到属性(map.packages)将被注入到包配置参数中,这意味着配置参数具有满足所需参数的值。 If you need having a property defined in combination with required you need to check in the execute() method. 如果需要将属性与required一起定义,则需要检入execute()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM